Vixen
dd8b0a81
csharp
public sealed class MaterialView

A material, open for editing: a preview, what it is drawn with, and what it sets.

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

Remarks

⚠ The preview is a request, not a renderer. Drawing a lit sphere needs a device, a compositor and a compiled effect, none of which this assembly has — so the view owns the Shape and the Preview image, raises PreviewChanged when either the shape or the material moves, and the application renders into a target and puts its number on the image. The same split the scene panel and the texture editor already have.

⚠ And the second half of that sentence is a plan rather than a description: nothing subscribes PreviewChanged, so the image is never given a texture number and the preview is blank in every editor built so far (#1204). The texture editor's equivalent is wired — TexturePreviewImages, from EditorApplication.Joined — and it uploads decoded texels, which is a far smaller job than rendering a lit shape; a material has no picture that is not a render of it, which is doc 20's E5 preview work. ⚠ The graph button is not in that state, and an audit that said so was wrong: Joined subscribes OpenGraphRequested, so "Open shader graph" opens the graph.

The shader-graph link is a button and a state. A material naming a graph offers "Open graph"; one that names a graph the project no longer has says so rather than offering a button that opens nothing. What happens when it is pressed is the shell's — OpenGraphRequested carries the asset, and the registry is what turns an asset into a document.

The panel is MaterialView.vxml; this file is the accessibility modifier, the preview-shape enumeration and the record the graph button is. ⚠ The parameter list is still built in C# and the ledger's sixth shape is why — every row feeds a sealed InspectorView by a method, inside a loop, which is the one thing no escape this document records can express.

Fields and properties (14)

  • protected override string TagName
  • protected override bool AcceptsFocus

    Whether the focus can rest on this kind of control at all.

  • public Image Preview

    Where the preview is drawn once something has rendered it.

  • public MaterialPreviewShape Shape

    Which shape the preview asks for.

  • public Select Shapes

    The shape picker.

  • public InspectorView HeaderView

    The shader, the shading model and the graph link.

  • public Button OpenGraph

    The button that opens the graph this material came from.

  • public UiElement Parameters

    What the material sets, one expander a parameter.

  • public Alert GraphBroken

    Says why the linked graph offers no properties, when it offers none.

  • public UiElement GraphProperties

    One row per property the linked graph asks a material to fill in.

  • public Select NewKind

    Which kind of parameter the add button will add.

  • public TextBox NewName

    What the new parameter will be called.

  • public Button AddParameter

    The button that adds it.

  • public Alert Broken

    Shown when the file did not read.

Events (2)

  • public Action<MaterialView>? PreviewChanged

    Raised when the preview's subject changes — a different shape, or an edited value.

  • public Action<MaterialView, AssetId>? OpenGraphRequested

    Raised when the author asks for the shader graph this material was authored in.

Methods (5)

  • protected override void OnCreated()
  • protected override void OnRemoved()
  • public void Show(MaterialDocument material)

    Shows a material.

  • public void Rebuild()

    Rebuilds the parameter list from the material as it stands.

  • public void Reload()

    Reads every editor back from the material, without rebuilding anything.

Used by (6)

  • EditorApplicationVixen.Editor.App
  • EditorViewTestsVixen.Editor.AssetEditors.Tests
  • MaterialEditorFactoryVixen.Editor.AssetEditors
  • MaterialGraphLinkTestsVixen.Editor.AssetEditors.Tests
  • MaterialGraphPropertyTestsVixen.Editor.AssetEditors.Tests
  • MaterialTestsVixen.Editor.AssetEditors.Tests