1. Home
  2. Docs
  3. Magio
  4. Tutorials
  5. Optimize if you have lots of inactive Magio Objects / Use custom instancer or renderer

Optimize if you have lots of inactive Magio Objects / Use custom instancer or renderer

Works with Magio version 1.0.0+

Example 1: You have a huge amount of box prefabs on the scene. You want to convert them all to magio, but with each active Magio object there is a small overhead.

Example 2: You are using Instance Indirect or some other GPU instancing using renderer. The method you are using spawns colliders and uses GPU to draw meshes. You want to use Magio with all objects.

Steps:

  1. Enable MagioEngine->Enable Mesh Prefab Replacers
  1. Open the prefab you want to use. Duplicate all the materials (If you do not want to use Magio materials on your in-active object). 
  2. Duplicate the prefab.
  3. Drag the duplicated prefab to the scene and convert it to Magio Object normally.
  4. You should now have two prefabs with two different materials.

“Normal” version:

Magio Version:

Project view:

  1. Attach a “Magio Mesh Prefab Replacer” component to the “normal” object without any Magio components. Assign the Magio Object you just created as the variant.
  1. Now your “normal” prefab should be replaced at runtime with Magio prefab.
  2. (Optional) If you want to have custom functionality done when the prefab is being replaced, e.g. mask an instance on renderer or something else, you can implement a class which inherits Magio Mesh Prefab Replacer. An example is here:
Was this article helpful to you? Yes No

Leave a Reply

Your email address will not be published.