@@ -23,6 +23,7 @@ public static class AssetManager
2323 public static Dictionary < string , AssetBundle > Bundles { get ; private set ; } = new Dictionary < string , AssetBundle > ( System . StringComparer . OrdinalIgnoreCase ) ;
2424 public static Dictionary < string , AssetBundle > AssetPaths { get ; private set ; } = new Dictionary < string , AssetBundle > ( System . StringComparer . OrdinalIgnoreCase ) ;
2525 public static Dictionary < string , Object > Cache { get ; private set ; } = new Dictionary < string , Object > ( ) ;
26+ public static Dictionary < string , Texture2D > Previews { get ; private set ; } = new Dictionary < string , Texture2D > ( ) ;
2627
2728 public static List < string > ManifestStrings { get => IsInitialised ? GetManifestStrings ( ) : new List < string > ( ) ; private set => ManifestStrings = value ; }
2829
@@ -86,6 +87,24 @@ public static GameObject LoadPrefab(string filePath)
8687 }
8788 }
8889
90+ public static Texture2D GetPreview ( string filePath )
91+ {
92+ if ( Previews . TryGetValue ( filePath , out Texture2D preview ) )
93+ return preview ;
94+ else
95+ {
96+ var prefab = LoadPrefab ( filePath ) ;
97+ if ( prefab . name == "DefaultPrefab" )
98+ return AssetPreview . GetAssetPreview ( prefab ) ;
99+
100+ prefab . SetActive ( true ) ;
101+ var tex = AssetPreview . GetAssetPreview ( prefab ) ?? new Texture2D ( 60 , 60 ) ;
102+ Previews . Add ( filePath , tex ) ;
103+ prefab . SetActive ( false ) ;
104+ return tex ;
105+ }
106+ }
107+
89108 private static List < string > GetManifestStrings ( )
90109 {
91110 if ( Manifest == null )
@@ -158,6 +177,7 @@ public static IEnumerator Initialise(string bundlesRoot)
158177 yield return EditorCoroutineUtility . StartCoroutineOwnerless ( SetMaterials ( materialID ) ) ;
159178
160179 IsInitialised = true ; IsInitialising = false ;
180+ EventManager . OnBundlesLoaded ( ) ;
161181 PrefabManager . ReplaceWithLoaded ( PrefabManager . CurrentMapPrefabs , prefabID ) ;
162182 }
163183
0 commit comments