// This code is commented out because it is no longer used. It used to // migrate data inside of the prefab into the scene object. Now, we just // don't store scene objects inside of the prefab (we lose the ability to // save the state from play-mode, but that's okay) /// <summary> /// Attempts to migrate prefab storage into scene storage. /// </summary> private static void MigratePrefabIntoSceneStorage <T>() where T : fiPersistentEditorStorageItem { // Only try to do the migration once (per type) if (_didMigrate.Add(typeof(T)) == false) { return; } // We cannot migrate data while playing -- scene storage will not be // persisted if (Application.isPlaying) { return; } var prefabStorage = PrefabStorage.GetComponent <fiBaseStorageComponent <T> >(); var sceneStorage = SceneStorage.GetComponent <fiBaseStorageComponent <T> >(); // Nothing to migrate. if (prefabStorage == null || prefabStorage.Data == null) { return; } // Migrate everything into scene storage var toRemove = new List <fiUnityObjectReference>(); foreach (var entry in prefabStorage.Data) { if (AssetDatabase.Contains(entry.Key.Target)) { // data should stay in prefab storage, as the UnityObject // target does not live in the scene continue; } if (sceneStorage.Data.ContainsKey(entry.Key) == false) { // move directly into scene storage sceneStorage.Data[entry.Key] = entry.Value; } else { // copy into scene storage sceneStorage.Data[entry.Key].CopyFromAndClear(prefabStorage.Data[entry.Key]); } toRemove.Add(entry.Key); } foreach (var item in toRemove) { prefabStorage.Data.Remove(item); } fiLateBindings.EditorUtility.SetDirty(sceneStorage); fiLateBindings.EditorUtility.SetDirty(prefabStorage); }