Vixen
dd8b0a81
csharp
public sealed class MaterialDocument

A material, open for editing.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

⚠ The header is a mirror and the parameters are not. A parameter object is already a class with settable members and its own descriptor, so the inspector edits it in place and every edit is a SetMembersCommand without anything here being involved. The header is mirrored only to keep Version and Parameters off the rows, and SaveCore copies the three fields back — which is three lines rather than a second schema.

⚠ A material whose file will not parse opens empty and says so through LoadError. Refusing to open it would leave the one panel that could show what is wrong unreachable, and the file is untouched until a save.

Fields and properties (7)

  • public string AssetPath

    Where the file is, absolute.

  • public MaterialAsset Material

    The material as it stands.

  • public MaterialHeaderEdits Header

    The three header fields, as an inspector edits them.

  • public string? LoadError

    Why the file did not read, or if it did.

  • public ShaderGraphSource? GraphSource

    The linked shader graph, compiled, or null when there is not one to compile.

  • public string? GraphProblem

    Why the linked graph produced no properties, or null when it did.

  • public GraphSurfaceFeature? Surface

    The one feature that carries this material's graph values, if it has one yet.

Events (1)

  • public Action<MaterialDocument>? ParametersChanged

    Raised when a parameter is added or removed.

Methods (8)

  • public MaterialDocument(EditorProject project, AssetId asset, string path)

    Opens a material.

  • public IMaterialParameter Add(IMaterialParameter parameter)

    Adds a parameter, undoably.

  • public bool Remove(IMaterialParameter parameter)

    Removes a parameter, undoably.

  • public void ReadGraph()

    Reads and compiles the graph Graph names.

  • public bool LinkGraph()

    Composes the linked graph as this material's surface, undoably.

  • public bool SetGraphValue(string property, Vector4 value)

    Sets one of the linked graph's properties, undoably.

  • public string ToYaml()

    The material as this document would write it, without writing it.

  • protected override void SaveCore()

    Writes the document back to wherever it came from.

Used by (10)

  • AssetEditorRegistryTestsVixen.Editor.AssetEditors.Tests
  • EditorViewTestsVixen.Editor.AssetEditors.Tests
  • MaterialEditorFactoryVixen.Editor.AssetEditors
  • MaterialGraphLinkCommandVixen.Editor.AssetEditors
  • MaterialGraphLinkTestsVixen.Editor.AssetEditors.Tests
  • MaterialGraphPropertyTestsVixen.Editor.AssetEditors.Tests
  • MaterialGraphValueCommandVixen.Editor.AssetEditors
  • MaterialParameterCommandVixen.Editor.AssetEditors
  • MaterialTestsVixen.Editor.AssetEditors.Tests
  • MaterialViewVixen.Editor.AssetEditors