[1.20] Dynamic Mesh Combiner
  • Quick Start
  • Components
    • Usage Tips
    • Combiner
      • MC Chunk Combiner
      • MC Mesh Combiner
    • MC Combinable
      • MC LOD Combinable
    • MC Extractor
    • Bake Materials
      • NoTextureMaterialBaker
      • TextureBaker
    • Profile
    • Compatible Assets
      • Photon
      • Outlines & Highlights
Powered by GitBook
On this page
  • Configuration
  • Key
  • Is Static
  • Disable Renderer
  • Remove Materials
  • What else?
  • Change mesh parent
  • Updating mesh or materials
  • Animation update
  • Optimize Game Objects
  • Enabled/Disable combinable
  • Component cache
  • Mark Mesh as Readable
  1. Components

MC Combinable

PreviousMC Mesh CombinerNextMC LOD Combinable

Combinable is one of the core components that needs to be added to all meshes you want to combine. It is compatible with both Skinned Mesh Renderer and Mesh Renderer components. In most cases, simply adding this component to the mesh will enable the baking process. However, there are additional configuration options and usage details that can help you achieve better results. These details include fine-tuning the settings and understanding how to optimize the combining process for improved outcomes.

Configuration

Key

That keyword used to determine which MC Combinable should be used to combine mesh. The component will find closest parent component that has specified key, or of parent key list is empty.

Note: If you have a parent object with multiple combiners, only the first matching combiner (from top to bottom) will be used. This means that if first combiner doesn't have any keys specified, then only that component will be used.

Is Static

This option controls how you want to bake the mesh.

  • When set to TRUE, the mesh will be baked into a Mesh Renderer and any animations or transform changes will be ignored. This is useful for static meshes that do not require animations or dynamic transformations.

  • When set to FALSE, the mesh will be baked into a Skinned Mesh Renderer. This allows the original animations to be preserved, and any transform changes will be applied to the baked mesh. This is suitable for cases where you want to retain the animated behavior or dynamically move/scale or rotate objects.

Please note that the output renderer will be chosen based on preferences.

Disable Renderer

When set to TRUE, the Disable Renderer property will disable the original Mesh Renderer or Skinned Mesh Renderer when the mesh is combined.

By default, this property is set to TRUE.

Remove Materials

The Remove Materials property controls whether all materials should be removed from the original Mesh Renderer or Skinned Mesh Renderer when the mesh is combined. If set to TRUE, the original materials will be removed, and only the combined material will be used. Materials will be restored when mesh is unbaked.

Please read Outlines & Highlights for more details when it's might be useful.

By default, this property is set to FALSE.

What else?

Change mesh parent

When you change the parent of a mesh, the mesh will automatically be moved to a new combiner if the parent meets certain conditions. The mesh will be re-baked to the appropriate combiner based on the new parent.

This functionality allows for seamless handling of mesh re-parenting, ensuring that the mesh is correctly associated with the appropriate combiner for combining and rendering.

Updating mesh or materials

This function will refresh the baked mesh to reflect any modifications made to the underlying mesh or materials. By invoking the UpdateStatus function, you ensure that the combined mesh stays up to date with any changes you have made.

Animation update

When the Combiner bakes a mesh, it will disable the original renderer for that mesh. In such cases, it is important to ensure that the Culling Mode is set to Always Animate on the Animator. Failing to do so may result in animation issues where the animation does not update properly when the mesh is baked. By setting the Culling Mode to Always Animate, you ensure that the animation continues to play correctly even after the mesh has been baked.

Optimize Game Objects

When working with animated meshes, it's essential to ensure that the "Optimize Game Objects" option is disabled. Enabling this option can lead to the removal of game objects associated with bones, resulting in the inability to combine meshes while preserving their transforms.

Enabled/Disable combinable

To bake or remove a mesh, you can simply enable or disable the Combinable component. When the Combinable component is enabled, the original renderer will be disabled as the mesh gets baked and combined. Conversely, when the Combinable component is disabled, the original renderer will be re-enabled, allowing the mesh to be rendered separately. This enables you to easily control whether the mesh is part of the combined result or rendered individually.

Component cache

To improve baking performance, the Combiner component caches links to the Mesh Renderer, Skinned Mesh Renderer, and Mesh Filter components. However, in rare cases, issues may arise, such as when adding components via a script. If you encounter such issues, it is recommended to call the SetRenderers function on the Combiner component, which will update the cache accordingly.

In general, using prefabs is much faster and more efficient, as there is a custom editor that automatically resets the cache in Editor mode. This means you don't need to manually reset the cache during runtime. Leveraging prefabs with the Combiner component can greatly streamline the process and ensure optimal performance.

You can view the cache value by enabling the debug mode in the inspector. This allows you to inspect and monitor the current cache status, providing visibility into the caching behavior of the Combiner component.

Mark Mesh as Readable

To access and combine mesh data using the Dynamic Mesh Combiner (DMC), you need to ensure that the mesh is marked as readable. By default, Unity automatically marks meshes as readable in the editor, but there are cases where a mesh may not be baked at least once, preventing it from being read in the executable build.

To mark a mesh as readable, follow these steps:

  1. Select the mesh you want to mark as readable in the Unity Editor.

  2. In the Inspector window, locate the "Read/Write Enabled" checkbox under the Mesh section.

  3. Enable the "Read/Write Enabled" checkbox to allow read and write access to the mesh data.

By marking the mesh as readable, you enable the DMC and other scripts to access and modify the mesh data as needed for combining. This step is crucial to ensure that the mesh can be properly processed and combined during runtime.

If the mesh has already been baked at least once in the editor, it will already be marked as readable, and you don't need to perform this step explicitly. However, it's important to keep in mind that any new meshes added to the project or instantiated at runtime will need to be marked as readable manually.

Ensure that you mark all the meshes that you intend to combine as readable to enable successful mesh combining with the DMC in your executable builds.

The Combiner component does not automatically detect changes in the mesh or material (if is enabled, then even material colors). If you want to update the combined mesh, you need to manually call the UpdateStatus function on the component.

Render Types
Bake Materials