/// <summary> /// stops managing the recycle bin optionally destroying all managed objects /// </summary> /// <param name="recycleBin">Recycle bin.</param> /// <param name="shouldDestroyAllManagedObjects">If set to <c>true</c> should destroy all managed objects.</param> public static void removeRecycleBin(TrashManRecycleBin recycleBin, bool shouldDestroyAllManagedObjects = true) { var recycleBinName = recycleBin.prefab.name; // make sure we are managing the bin first if (instance._poolNameToInstanceId.ContainsKey(recycleBinName)) { instance._poolNameToInstanceId.Remove(recycleBinName); instance._instanceIdToRecycleBin.Remove(recycleBin.prefab.GetInstanceID()); instance.recycleBinCollection.Remove(recycleBin); recycleBin.clearBin(shouldDestroyAllManagedObjects); } }
/// <summary> /// tells TrashMan to start managing the recycle bin at runtime /// </summary> /// <param name="recycleBin">Recycle bin.</param> public static void manageRecycleBin(TrashManRecycleBin recycleBin) { // make sure we can safely add the bin! if (instance._poolNameToInstanceId.ContainsKey(recycleBin.prefab.name)) { Debug.LogError("Cannot manage the recycle bin because there is already a GameObject with the name (" + recycleBin.prefab.name + ") being managed"); return; } instance.recycleBinCollection.Add(recycleBin); recycleBin.initialize(); instance._instanceIdToRecycleBin.Add(recycleBin.prefab.GetInstanceID(), recycleBin); instance._poolNameToInstanceId.Add(recycleBin.prefab.name, recycleBin.prefab.GetInstanceID()); }