Class MergedModel
Merges meshes found in a transform's hierarchy and provides (optional) custom merging behavior with the specified IMergeBehavior behavior(s).
Namespace: Unity.Industrial.Forma.Core.MeshMerge
Syntax
public class MergedModel
Constructors
MergedModel(Transform, IMergeBehavior[])
Creates a MergedModel instance.
Declaration
public MergedModel(Transform rootNode, params IMergeBehavior[] behaviors)
Parameters
Type | Name | Description |
---|---|---|
Transform | rootNode | Node that will have its hierarchy merged. |
IMergeBehavior[] | behaviors | Merge behaviors to apply to the MergedModel. |
Properties
Meshes
Meshes that were created in the merge.
Declaration
public List<Mesh> Meshes { get; }
Property Value
Type | Description |
---|---|
List<Mesh> |
Root
Merged model's root transform.
Declaration
public Transform Root { get; }
Property Value
Type | Description |
---|---|
Transform |
Methods
AddRootNode(Transform)
A new sub-hierarchy will be created in the merged model when the specified root is encountered in the merging process.
Declaration
public void AddRootNode(Transform rootNode)
Parameters
Type | Name | Description |
---|---|---|
Transform | rootNode | Root that will be added to the merged model. |
AddRootNode(Transform, Guid)
A new sub-hierarchy will be created in the merged model when the specified root is encountered in the merging process.
Declaration
public void AddRootNode(Transform rootNode, Guid batchId)
Parameters
Type | Name | Description |
---|---|---|
Transform | rootNode | Root that will be added to the merged model. |
Guid | batchId | A batch ID can be provided to potentially merge different root nodes together. Different roots will be merged if they have the same batch ID and the same parent on the merged model. |
BatchSubMeshes(IEnumerable<SubMeshRenderer>)
Sub-meshes will be batched together so they can be referenced after the model has been merged. Batched sub-meshes won't be merged with non-batched sub-meshes or sub-meshes within a different batch, even if they share the same material and lighting properties.
Declaration
public Guid BatchSubMeshes(IEnumerable<SubMeshRenderer> subMeshRenderers)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<SubMeshRenderer> | subMeshRenderers | Sub-meshes that will be batched together. |
Returns
Type | Description |
---|---|
Guid | ID of the batch that the sub-meshes were added to. |
Remarks
Non-batched sub-meshes that share the same material and lighting properties will be batched together in a "default" batch.
ExcludeRendererFromMerge(Renderer)
Excluding a renderer will prevent it from being merged with other meshes.
Declaration
public void ExcludeRendererFromMerge(Renderer renderer)
Parameters
Type | Name | Description |
---|---|---|
Renderer | renderer | Renderer to exclude from merge. |
TryGetMappedRootNode(Transform, out Transform)
Gets the mapped root node on the merged model associated with the specified root.
Declaration
public bool TryGetMappedRootNode(Transform originalRoot, out Transform mappedRoot)
Parameters
Type | Name | Description |
---|---|---|
Transform | originalRoot | Original model's root node. |
Transform | mappedRoot | Mapped root node on the merged model. |
Returns
Type | Description |
---|---|
Boolean |
|
TryGetMappedSubMeshBatch(Guid, out IReadOnlyList<SubMeshRenderer>)
Gets the sub-mesh renderers that were remapped on the merged model.
Declaration
public bool TryGetMappedSubMeshBatch(Guid batchId, out IReadOnlyList<SubMeshRenderer> subMeshRenderers)
Parameters
Type | Name | Description |
---|---|---|
Guid | batchId | Batch ID of the remapped sub-mesh renderers. |
IReadOnlyList<SubMeshRenderer> | subMeshRenderers | Mapped sub-mesh renderers on the merged model. |
Returns
Type | Description |
---|---|
Boolean |
|