@@ -55,6 +55,7 @@ public static GameObject Process(GameObject go, string filePath)
5555 }
5656 PrefabDataHolder prefabDataHolder = go . AddComponent < PrefabDataHolder > ( ) ;
5757 prefabDataHolder . prefabData = new PrefabData ( ) { id = AssetManager . ToID ( filePath ) } ;
58+ prefabDataHolder . Setup ( ) ;
5859 return go ;
5960 }
6061
@@ -107,53 +108,22 @@ private static class Coroutines
107108 public static IEnumerator SpawnPrefabs ( PrefabData [ ] prefabs )
108109 {
109110 IsBusy = true ;
110- yield return EditorCoroutineUtility . StartCoroutineOwnerless ( PreparePrefabsCoroutine ( prefabs ) ) ;
111111 yield return EditorCoroutineUtility . StartCoroutineOwnerless ( SpawnPrefabsCoroutine ( prefabs ) ) ;
112112 IsBusy = false ;
113113 }
114114
115- private static IEnumerator PreparePrefabsCoroutine ( PrefabData [ ] prefabs )
115+ public static IEnumerator ReplaceWithLoaded ( PrefabDataHolder [ ] prefabs )
116116 {
117- System . Diagnostics . Stopwatch sw = new System . Diagnostics . Stopwatch ( ) ;
118- sw . Start ( ) ;
119-
120- ProgressBarManager . SetProgressIncrement ( 1f / prefabs . Length ) ;
121- for ( int i = 0 ; i < prefabs . Length ; i ++ )
122- {
123- if ( sw . Elapsed . TotalSeconds > 0.1f )
124- {
125- sw . Restart ( ) ;
126- ProgressBarManager . DisplayIncremental ( "Processing Prefabs" , "Loading Prefabs: " + i + " / " + prefabs . Length ) ;
127- yield return null ;
128- }
129- else
130- ProgressBarManager . AddIncrement ( ) ;
131-
132- Load ( prefabs [ i ] . id ) ;
133- }
134- ProgressBarManager . Clear ( ) ;
117+ IsBusy = true ;
118+ yield return EditorCoroutineUtility . StartCoroutineOwnerless ( ReplaceWithLoadedCoroutine ( prefabs ) ) ;
119+ IsBusy = false ;
135120 }
136121
137- private static IEnumerator PreparePrefabsCoroutine ( PrefabDataHolder [ ] prefabs )
122+ public static IEnumerator ReplaceWithDefault ( PrefabDataHolder [ ] prefabs )
138123 {
139- System . Diagnostics . Stopwatch sw = new System . Diagnostics . Stopwatch ( ) ;
140- sw . Start ( ) ;
141-
142- ProgressBarManager . SetProgressIncrement ( 1f / prefabs . Length ) ;
143- for ( int i = 0 ; i < prefabs . Length ; i ++ )
144- {
145- if ( sw . Elapsed . TotalSeconds > 0.1f )
146- {
147- sw . Restart ( ) ;
148- ProgressBarManager . DisplayIncremental ( "Processing Prefabs" , "Loading Prefabs: " + i + " / " + prefabs . Length ) ;
149- yield return null ;
150- }
151- else
152- ProgressBarManager . AddIncrement ( ) ;
153-
154- Load ( prefabs [ i ] . prefabData . id ) ;
155- }
156- ProgressBarManager . Clear ( ) ;
124+ IsBusy = true ;
125+ yield return EditorCoroutineUtility . StartCoroutineOwnerless ( ReplaceWithDefaultCoroutine ( prefabs ) ) ;
126+ IsBusy = false ;
157127 }
158128
159129 private static IEnumerator SpawnPrefabsCoroutine ( PrefabData [ ] prefabs )
@@ -164,7 +134,7 @@ private static IEnumerator SpawnPrefabsCoroutine(PrefabData[] prefabs)
164134 ProgressBarManager . SetProgressIncrement ( 1f / prefabs . Length ) ;
165135 for ( int i = 0 ; i < prefabs . Length ; i ++ )
166136 {
167- if ( sw . Elapsed . TotalSeconds > 0.1f )
137+ if ( sw . Elapsed . TotalSeconds > 2f )
168138 {
169139 sw . Restart ( ) ;
170140 ProgressBarManager . DisplayIncremental ( "Spawning Prefabs" , "Spawning Prefabs: " + i + " / " + prefabs . Length ) ;
@@ -178,14 +148,6 @@ private static IEnumerator SpawnPrefabsCoroutine(PrefabData[] prefabs)
178148 ProgressBarManager . Clear ( ) ;
179149 }
180150
181- public static IEnumerator ReplaceWithLoaded ( PrefabDataHolder [ ] prefabs )
182- {
183- IsBusy = true ;
184- yield return EditorCoroutineUtility . StartCoroutineOwnerless ( PreparePrefabsCoroutine ( prefabs ) ) ;
185- yield return EditorCoroutineUtility . StartCoroutineOwnerless ( ReplaceWithLoadedCoroutine ( prefabs ) ) ;
186- IsBusy = false ;
187- }
188-
189151 private static IEnumerator ReplaceWithLoadedCoroutine ( PrefabDataHolder [ ] prefabs )
190152 {
191153 System . Diagnostics . Stopwatch sw = new System . Diagnostics . Stopwatch ( ) ;
@@ -194,7 +156,7 @@ private static IEnumerator ReplaceWithLoadedCoroutine(PrefabDataHolder[] prefabs
194156 ProgressBarManager . SetProgressIncrement ( 1f / prefabs . Length ) ;
195157 for ( int i = 0 ; i < prefabs . Length ; i ++ )
196158 {
197- if ( sw . Elapsed . TotalSeconds > 0.1f )
159+ if ( sw . Elapsed . TotalSeconds > 2f )
198160 {
199161 ProgressBarManager . DisplayIncremental ( "Replacing Prefabs" , "Spawning Prefabs: " + i + " / " + prefabs . Length ) ;
200162 yield return null ;
@@ -209,13 +171,6 @@ private static IEnumerator ReplaceWithLoadedCoroutine(PrefabDataHolder[] prefabs
209171 ProgressBarManager . Clear ( ) ;
210172 }
211173
212- public static IEnumerator ReplaceWithDefault ( PrefabDataHolder [ ] prefabs )
213- {
214- IsBusy = true ;
215- yield return EditorCoroutineUtility . StartCoroutineOwnerless ( ReplaceWithDefaultCoroutine ( prefabs ) ) ;
216- IsBusy = false ;
217- }
218-
219174 private static IEnumerator ReplaceWithDefaultCoroutine ( PrefabDataHolder [ ] prefabs )
220175 {
221176 System . Diagnostics . Stopwatch sw = new System . Diagnostics . Stopwatch ( ) ;
0 commit comments