static bool SpawnInternal( NestedPrefab prefabInstance, List <GameObject> previouslyInstantiated ) { GameObject instantiated = prefabInstance.InstantiateSelf(previouslyInstantiated); if (instantiated == null) { return(false); } prefabInstance.Setup(); // BUG: If not set dirty here .instantiated is not properly saved #if UNITY_EDITOR if (!Application.isPlaying) { EditorUtility.SetDirty(prefabInstance); EditorUtility.SetDirty(prefabInstance.gameObject); } #endif // UNITY_EDITOR return(true); }
static void SpawnInternal( NestedPrefab prefabInstance, List <NestedPrefab> queue, List <GameObject> previouslyInstantiated ) { GameObject instantiated = prefabInstance.InstantiateSelf(previouslyInstantiated); if (instantiated == null) { return; } prefabInstance.Setup(); // BUG: If not set dirty here .instantiated is not properly saved #if UNITY_EDITOR if (!Application.isPlaying) { EditorUtility.SetDirty(prefabInstance); EditorUtility.SetDirty(prefabInstance.gameObject); } #endif // UNITY_EDITOR // Enqueue all child NestedPrefab prefabInstance.GetComponentsInChildren <NestedPrefab>( includeInactive: true, result: queue ); queue.Remove(prefabInstance); // TODO: Fix this //// Remove all NestedPrefab that shares the //// same prefab (this includes the prefab itself //// and any child that may be nested) //for(int i = queue.Count - 1; i >= 0; --i) //{ // NestedPrefab iter = queue[i]; // if(iter.prefab == prefabInstance.prefab) // { // Dbg.LogErrorIf( // iter != prefabInstance, // iter, // "{0} was already instantiated in this hierarchy. It will not be instantiated to avoid recursion.", // iter.prefab // ); // queue.RemoveAt(i); // } //} }