private void Start()
 {
     if (gpuiPrefab.state == PrefabInstancingState.None)
     {
         GPUInstancerPrefabManager prefabManager = GetPrefabManager();
         if (prefabManager != null)
         {
             prefabManager.AddPrefabInstance(gpuiPrefab, true);
         }
     }
 }
 private void OnEnable()
 {
     if (gpuiPrefab.state == PrefabInstancingState.None)
     {
         if (_prefabManager == null)
         {
             _prefabManager = GetPrefabManager();
         }
         if (_prefabManager != null)
         {
             if (!_prefabManager.isInitialized)
             {
                 _prefabManager.InitializeRuntimeDataAndBuffers();
             }
             _prefabManager.AddPrefabInstance(gpuiPrefab, true);
         }
     }
 }
Example #3
0
 /// <summary>
 ///     <para>Adds a new prefab instance for GPU instancing to an already initialized list of registered instances. </para>
 ///     <para>Use this if you want to add another instance of a prefab after you have initialized a list of prefabs with <see cref="InitializeGPUInstancer"/>.</para>
 ///     <para>The prefab of this instance must be previously defined in the given manager (either at runtime or editor time).</para>
 ///     <para>Note that the prefab must be enabled for adding and removal in the manager in order for this to work (for performance reasons).</para>
 ///     <para>Also note that the number of total instances is limited by the count of already initialized instances plus the extra amount you define in the manager.</para>
 /// </summary>
 /// <param name="manager">The manager that defines the prototypes you want to GPU instance.</param>
 /// <param name="prefabInstance">The prefab instance to add.</param>
 public static void AddPrefabInstance(GPUInstancerPrefabManager manager, GPUInstancerPrefab prefabInstance)
 {
     manager.AddPrefabInstance(prefabInstance);
 }