@@ -225,7 +225,7 @@ Assembly Resolve(object sender, ResolveEventArgs args)
225
225
var toPreload = new Dictionary < string , List < ( ModInstance , List < string > objectNames ) > > ( ) ;
226
226
// dict<scene name, list<(mod, list<objectNames>)>
227
227
var preloadPrefabs = new Dictionary < string , List < ( ModInstance , List < string > objectNames ) > > ( ) ;
228
- // dict<mod, dict<real scene name, scene naem in getpreloadobjects>>
228
+ // dict<mod, dict<real scene name, scene name in getpreloadobjects>>
229
229
var sceneNamesMap = new Dictionary < ModInstance , Dictionary < string , string > > ( ) ;
230
230
// dict<mod, dict<scene, dict<objName, object>>>
231
231
var preloadedObjects = new Dictionary < ModInstance , Dictionary < string , Dictionary < string , GameObject > > > ( ) ;
@@ -321,11 +321,8 @@ Dictionary<ModInstance, Dictionary<string, string>> sceneNamesMap
321
321
// dict<scene, list<objects>>
322
322
Dictionary < string , List < string > > prefabPreloads = new ( ) ;
323
323
324
- if ( ! sceneNamesMap . TryGetValue ( mod , out var sceneNames ) )
325
- {
326
- sceneNames = new ( ) ;
327
- sceneNamesMap [ mod ] = sceneNames ;
328
- }
324
+ if ( ! sceneNamesMap . TryGetValue ( mod , out var sceneNames ) )
325
+ sceneNamesMap [ mod ] = sceneNames = new Dictionary < string , string > ( ) ;
329
326
330
327
foreach ( ( string scene , string obj ) in preloadNames )
331
328
{
@@ -341,28 +338,33 @@ Dictionary<ModInstance, Dictionary<string, string>> sceneNamesMap
341
338
if ( ! sceneName . Equals ( "resources" ) )
342
339
{
343
340
if ( ! int . TryParse ( sceneName . Substring ( 12 ) , out var sceneId ) )
344
- {
345
341
continue ;
346
- }
342
+
347
343
if ( sceneId >= UnityEngine . SceneManagement . SceneManager . sceneCountInBuildSettings )
348
344
{
349
345
Logger . APILogger . LogWarn (
350
346
$ "Mod `{ mod . Mod . GetName ( ) } ` attempted preload from non-existent assets file `{ scene } .assets`"
351
347
) ;
352
348
continue ;
353
349
}
354
- var origSceneName = sceneName ;
350
+
351
+ string origSceneName = sceneName ;
352
+
355
353
sceneName = Path . GetFileNameWithoutExtension (
356
354
SceneUtility . GetScenePathByBuildIndex ( sceneId )
357
- ) ;
355
+ ) ;
356
+
358
357
sceneNames [ sceneName ] = origSceneName ;
359
358
}
359
+
360
360
if ( ! prefabPreloads . TryGetValue ( sceneName , out List < string > prefabs ) )
361
361
{
362
362
prefabs = new List < string > ( ) ;
363
363
prefabPreloads [ sceneName ] = prefabs ;
364
364
}
365
+
365
366
prefabs . Add ( obj ) ;
367
+
366
368
Logger . APILogger . LogFine ( $ "Found prefab `{ scene } .{ obj } `") ;
367
369
continue ;
368
370
}
@@ -399,6 +401,7 @@ Dictionary<ModInstance, Dictionary<string, string>> sceneNamesMap
399
401
scenePreloads . Add ( ( mod , objects ) ) ;
400
402
toPreload [ scene ] = scenePreloads ;
401
403
}
404
+
402
405
foreach ( ( string scene , List < string > objects ) in prefabPreloads )
403
406
{
404
407
if ( ! preloadedPrefabs . TryGetValue ( scene , out var scenePreloads ) )
@@ -418,7 +421,9 @@ Dictionary<ModInstance, Dictionary<string, string>> sceneNamesMap
418
421
private static void UpdateModText ( )
419
422
{
420
423
StringBuilder builder = new StringBuilder ( ) ;
424
+
421
425
builder . AppendLine ( "Modding API: " + ModHooks . ModVersion ) ;
426
+
422
427
foreach ( ModInstance mod in ModInstances )
423
428
{
424
429
if ( mod . Error is not ModErrorState err )
0 commit comments