@@ -65,7 +65,7 @@ private static string GetIndentation(int identation)
6565 return stringBuilder . ToString ( ) ;
6666 }
6767
68- public static void AppendHeader ( StreamWriter writer , ref int identation , string nameSpace , string className ,
68+ public static void AppendHeader ( StreamWriter writer , ref int identation , string nameSpace , string classAttributes , string className ,
6969 bool isPartial , bool isStatic , params string [ ] directives )
7070 {
7171 writer . WriteLine ( "// Automatically generated" ) ;
@@ -92,6 +92,9 @@ public static void AppendHeader(StreamWriter writer, ref int identation, string
9292 identation ++ ;
9393 }
9494
95+ if ( ! string . IsNullOrEmpty ( classAttributes ) )
96+ writer . WriteLine ( $ "{ GetIndentation ( identation ) } { classAttributes } ") ;
97+
9598 string finalClassDeclaration = "" ;
9699 finalClassDeclaration += GetIndentation ( identation ) ;
97100 finalClassDeclaration += "public " ;
@@ -109,6 +112,43 @@ public static void AppendHeader(StreamWriter writer, ref int identation, string
109112
110113 identation ++ ;
111114 }
115+
116+
117+ public static void AppendHeader ( StreamWriter writer , ref int identation , string nameSpace , string classAttributes , string classDeclaration , params string [ ] directives )
118+ {
119+ writer . WriteLine ( "// Automatically generated" ) ;
120+ writer . WriteLine ( "//" ) ;
121+ writer . WriteLine ( ) ;
122+ for ( int i = 0 ; i < directives . Length ; i ++ )
123+ {
124+ string directive = directives [ i ] ;
125+
126+ if ( string . IsNullOrEmpty ( directive ) )
127+ continue ;
128+
129+ writer . WriteLine ( $ "using { directive } ;") ;
130+ }
131+
132+ writer . WriteLine ( ) ;
133+
134+ bool hasNameSpace = ! string . IsNullOrEmpty ( nameSpace ) ;
135+ if ( hasNameSpace )
136+ {
137+ writer . WriteLine ( $ "namespace { nameSpace } ") ;
138+ writer . WriteLine ( "{" ) ;
139+
140+ identation ++ ;
141+ }
142+
143+ if ( ! string . IsNullOrEmpty ( classAttributes ) )
144+ writer . WriteLine ( $ "{ GetIndentation ( identation ) } { classAttributes } ") ;
145+
146+ writer . WriteLine ( $ "{ GetIndentation ( identation ) } { classDeclaration } ") ;
147+ writer . WriteLine ( GetIndentation ( identation ) + "{" ) ;
148+
149+ identation ++ ;
150+ }
151+
112152
113153 public static void AppendLine ( StreamWriter writer , int identation , string input = "" )
114154 {
@@ -157,7 +197,7 @@ public static void GenerateStaticCollectionScript(ScriptableObjectCollection col
157197 directives . Add ( collection . GetType ( ) . Namespace ) ;
158198 directives . AddRange ( GetCollectionDirectives ( collection ) ) ;
159199
160- AppendHeader ( writer , ref indentation , nameSpace ,
200+ AppendHeader ( writer , ref indentation , nameSpace , "" ,
161201 collection . GetCollectionType ( ) . Name , true , false , directives . Distinct ( ) . ToArray ( ) ) ;
162202
163203 GeneratedStaticFileType staticFileTypeForCollection = ScriptableObjectCollectionSettings . Instance . GetStaticFileTypeForCollection ( collection ) ;
0 commit comments