public void SetCache(GameObject prefabInstance, PrefabContentKey contentKey) { PrefabCacheTrackerComponent prefabCacheTrackerComponent = prefabInstance.AddComponent <PrefabCacheTrackerComponent>(); prefabCacheTrackerComponent.SetContentKey(contentKey); prefabCacheTrackerComponent.ObjectDestroyed += onPrefabInstanceDestroyed; cachedPrefabs.Add(prefabCacheTrackerComponent); }
private void onPrefabInstanceDestroyed(PrefabCacheTrackerComponent trackerComponent) { trackerComponent.ObjectDestroyed -= onPrefabInstanceDestroyed; cachedPrefabs.Remove(trackerComponent); gameObjectContentCache.Release(trackerComponent.ContentKey); }