@@ -13,13 +13,12 @@ public class MetadataLookupPreprocessBuild : IPreprocessBuildWithReport
1313{
1414 public int callbackOrder { get { return 0 ; } }
1515
16- public static List < ( string , Metadata ) > GetAllMetadata < Asset , Metadata > ( )
17- where Asset : UnityEngine . Object
18- where Metadata : CustomAssetMetadata
16+ public static List < ( string , CustomAssetMetadata ) > GetAllMetadata < Asset > ( )
17+ where Asset : UnityEngine . Object
1918 {
2019 // TODO: figure out if there's a more efficient way of doing this??
2120 var guids = AssetDatabase . FindAssets ( $ "t:{ typeof ( Asset ) . Name } ") ;
22- var result = new List < ( string , Metadata ) > ( ) ;
21+ var result = new List < ( string , CustomAssetMetadata ) > ( ) ;
2322 for ( int i = 0 ; i < guids . Length ; i ++ )
2423 {
2524 var assetPath = AssetDatabase . GUIDToAssetPath ( guids [ i ] ) ;
@@ -30,10 +29,10 @@ public class MetadataLookupPreprocessBuild : IPreprocessBuildWithReport
3029 int index = 0 ;
3130 foreach ( var item in AssetDatabase . LoadAllAssetsAtPath ( assetPath ) )
3231 {
33- if ( item is Metadata t && t . asset is Asset )
32+ if ( item is CustomAssetMetadata metadata && metadata . asset is Asset )
3433 {
3534 var name = $ "{ guids [ i ] } -{ index } ";
36- result . Add ( ( name , t ) ) ;
35+ result . Add ( ( name , metadata ) ) ;
3736 index ++ ;
3837 }
3938 }
@@ -54,7 +53,7 @@ public void OnPreprocessBuild(BuildReport report)
5453 var list = ScriptableObject . CreateInstance < MetadataLookupAsset > ( ) ;
5554 var allMetadata = new List < CustomAssetMetadata > ( ) ;
5655 // TODO: use addressables (if available?) instead to avoid loading every asset into memory
57- foreach ( var ( name , metadata ) in GetAllMetadata < UnityEngine . Object , CustomAssetMetadata > ( ) )
56+ foreach ( var ( name , metadata ) in GetAllMetadata < Material > ( ) ) // TODO: figure out a way to efficiently support more types
5857 {
5958 var clone = UnityEngine . Object . Instantiate ( metadata ) ;
6059 AssetDatabase . CreateAsset ( clone , $ "{ basePath } /{ name } .asset") ;
0 commit comments