ModelComponent

Reusable model rendering behavior that can be attached to any Node.

Properties

Model

(AssetReference?) { get; set }: Gets or sets the model asset reference. Every submesh of the model is drawn.

Mesh

(AssetReference?) { get; set }: Gets or sets the mesh asset reference. When set it takes precedence over Model, and only the mesh's submesh range is drawn.

Materials

(List<AssetReference?>) { get; set } = []: Gets or sets the per-submesh material overrides, Unity's MeshRenderer.sharedMaterials[] equivalent. Index order matches the model's submeshes; a null or missing entry uses the material the importer derived from the source file for that submesh.

ModelOverride

(Model?) { get; set }: Gets or sets a model to draw instead of resolving Model/Mesh. Runtime-only — never serialized — for editor tooling that renders a procedural mesh with no backing asset, such as the material preview's display quad.

ModelInstance

(Model?) : Gets the loaded runtime model.

ModelAssetId

(Guid): Gets the id of the model asset this component draws from, or Empty when neither reference resolves.

Public Methods

TryGetSubMeshRange

public bool TryGetSubMeshRange(int start, int count)

Gets the submesh range this component draws.

Parameters:

  • start (int): Index of the first submesh to draw.
  • count (int): Number of consecutive submeshes to draw.

Returns: bool

  • true when a Mesh narrows the range; false to draw the whole model.

Dispose

public void Dispose()

Releases this component's reference to the cached model.