private void OnDisable()
 {
     if (gpuiPrefab.state == PrefabInstancingState.Instanced)
     {
         GPUInstancerPrefabManager prefabManager = GetPrefabManager();
         if (prefabManager != null)
         {
             prefabManager.RemovePrefabInstance(gpuiPrefab);
         }
     }
 }
 private void OnDisable()
 {
     if (gpuiPrefab.state == PrefabInstancingState.Instanced)
     {
         if (_prefabManager == null)
         {
             _prefabManager = GetPrefabManager();
         }
         if (_prefabManager != null && !_prefabManager.isQuiting)
         {
             _prefabManager.RemovePrefabInstance(gpuiPrefab, false);
         }
     }
 }
Example #3
0
 /// <summary>
 ///     <para>Removes a prefab instance from an already initialized list of registered instances. </para>
 ///     <para>Use this if you want to remove a prefab instance after you have initialized a list of prefabs with <see cref="InitializeGPUInstancer"/>
 ///     (usually before destroying the GameObject).</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>
 /// </summary>
 /// <param name="manager">The manager that defines the prototypes you want to GPU instance.</param>
 /// <param name="prefabInstance">The prefab instance to remove.</param>
 /// <param name="setRenderersEnabled">If set to false Mesh Renderer components will not be enabled after removing prefab instance which will make the
 /// instance invisible.</param>
 public static void RemovePrefabInstance(GPUInstancerPrefabManager manager, GPUInstancerPrefab prefabInstance, bool setRenderersEnabled = true)
 {
     manager.RemovePrefabInstance(prefabInstance, setRenderersEnabled);
 }
Example #4
0
 /// <summary>
 ///     <para>Removes a prefab instance from an already initialized list of registered instances. </para>
 ///     <para>Use this if you want to remove a prefab instance after you have initialized a list of prefabs with <see cref="InitializeGPUInstancer"/>
 ///     (usually before destroying the GameObject).</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>
 /// </summary>
 /// <param name="manager">The manager that defines the prototypes you want to GPU instance.</param>
 /// <param name="prefabInstance">The prefab instance to remove.</param>
 public static void RemovePrefabInstance(GPUInstancerPrefabManager manager, GPUInstancerPrefab prefabInstance)
 {
     manager.RemovePrefabInstance(prefabInstance);
 }