@@ -6,6 +6,60 @@ namespace BrunoMikoski.ScriptableObjectCollections
66{
77 public static class SOCollectionsProjectContextMenus
88 {
9+ [ MenuItem ( "Tools/ScriptableObjectCollection/Generate All Static Access Files" , priority = 2000 ) ]
10+ private static void GenerateAllStaticAccessFiles ( )
11+ {
12+ CollectionsRegistry . Instance . ReloadCollections ( ) ;
13+
14+ int generatedCount = 0 ;
15+ IReadOnlyList < ScriptableObjectCollection > collections = CollectionsRegistry . Instance . Collections ;
16+ for ( int i = 0 ; i < collections . Count ; i ++ )
17+ {
18+ ScriptableObjectCollection collection = collections [ i ] ;
19+ if ( ! CodeGenerationUtility . DoesStaticFileForCollectionExist ( collection ) )
20+ continue ;
21+
22+ CodeGenerationUtility . GenerateStaticCollectionScript ( collection ) ;
23+ generatedCount ++ ;
24+ }
25+
26+ AssetDatabase . Refresh ( ) ;
27+ Debug . Log ( $ "[SOC] Generated static access files for { generatedCount } collections.") ;
28+ }
29+
30+ [ MenuItem ( "Tools/ScriptableObjectCollection/Generate All Static Access Files" , validate = true ) ]
31+ private static bool Validate_GenerateAllStaticAccessFiles ( )
32+ {
33+ return ! EditorApplication . isPlaying ;
34+ }
35+
36+
37+ [ MenuItem ( "Tools/ScriptableObjectCollection/Generate Indirect Access for All Collection" , priority = 2000 ) ]
38+ private static void GenerateIndirectAccessToAllKnowCollection ( )
39+ {
40+ CollectionsRegistry . Instance . ReloadCollections ( ) ;
41+
42+ int generatedCount = 0 ;
43+ IReadOnlyList < ScriptableObjectCollection > collections = CollectionsRegistry . Instance . Collections ;
44+ for ( int i = 0 ; i < collections . Count ; i ++ )
45+ {
46+ ScriptableObjectCollection collection = collections [ i ] ;
47+
48+ CodeGenerationUtility . GenerateIndirectAccessForCollectionItemType ( collection . GetItemType ( ) ) ;
49+ generatedCount ++ ;
50+ }
51+
52+ AssetDatabase . Refresh ( ) ;
53+ Debug . Log ( $ "[SOC] Generated indirect access files for { generatedCount } collections.") ;
54+ }
55+
56+ [ MenuItem ( "Tools/ScriptableObjectCollection/Generate Indirect Access for All Collection" , validate = true ) ]
57+ private static bool Validate_GenerateIndirectAccessToAllKnowCollection ( )
58+ {
59+ return ! EditorApplication . isPlaying ;
60+ }
61+
62+
963 [ MenuItem ( "Assets/Move to Different Collection" , true , priority = 10000 ) ]
1064 private static bool ValidateMoveToDifferentCollection ( )
1165 {
@@ -95,4 +149,4 @@ private static void SelectCollection()
95149 Selection . activeObject = socItem . Collection ;
96150 }
97151 }
98- }
152+ }
0 commit comments