12
12
public class EmbedLibraryWindow : EditorWindow
13
13
{
14
14
[ MenuItem ( MSSConstants . WINDOW_PATH + "/Embed Library" ) ]
15
- public static void ShowExample ( )
15
+ public static void CreateWindow ( )
16
16
{
17
- EmbedLibraryWindow wnd = GetWindow < EmbedLibraryWindow > ( ) ;
18
- wnd . titleContent = new GUIContent ( "Embed Library" ) ;
17
+ var window = GetWindow < EmbedLibraryWindow > ( ) ;
18
+ window . titleContent = new GUIContent ( "Embed Library" ) ;
19
19
}
20
20
21
21
[ Serializable ]
22
- private class librarySettings
22
+ private class LibrarySettings
23
23
{
24
24
public string nmsc ;
25
25
public string variableSink ;
@@ -114,17 +114,21 @@ private void EmbedButtonOnclick()
114
114
Directory . Delete ( path + "/ModularShaderSystem" , true ) ;
115
115
116
116
CopyDirectory ( PATH , path , "" , false ) ;
117
+
118
+ string licencePath = PATH . Replace ( "Editor" , "LICENSE" ) ;
119
+ if ( File . Exists ( licencePath ) )
120
+ File . Copy ( licencePath , path + "/ModularShaderSystem/LICENSE" ) ;
117
121
118
122
AssetDatabase . Refresh ( ) ;
119
123
}
120
124
121
- public void SaveSettingsOnFile ( )
125
+ private void SaveSettingsOnFile ( )
122
126
{
123
127
string path = EditorUtility . SaveFilePanel ( "Save settings to file" , "Assets" , "embedSettings.json" , "json" ) ;
124
128
if ( path . Length == 0 )
125
129
return ;
126
130
127
- librarySettings settings = new librarySettings
131
+ LibrarySettings settings = new LibrarySettings
128
132
{
129
133
nmsc = _namespaceField . value ,
130
134
variableSink = _variableKeywordField . value ,
@@ -140,7 +144,7 @@ public void SaveSettingsOnFile()
140
144
File . WriteAllText ( path , JsonUtility . ToJson ( settings ) ) ;
141
145
}
142
146
143
- public void LoadSettingsFromFile ( )
147
+ private void LoadSettingsFromFile ( )
144
148
{
145
149
string path = EditorUtility . OpenFilePanel ( "Load settings" , "Assets" , "json" ) ;
146
150
if ( ! File . Exists ( path ) )
@@ -149,7 +153,7 @@ public void LoadSettingsFromFile()
149
153
return ;
150
154
}
151
155
152
- var settings = JsonUtility . FromJson < librarySettings > ( File . ReadAllText ( path ) ) ;
156
+ var settings = JsonUtility . FromJson < LibrarySettings > ( File . ReadAllText ( path ) ) ;
153
157
154
158
_namespaceField . value = settings . nmsc ;
155
159
_variableKeywordField . value = settings . variableSink ;
@@ -171,31 +175,9 @@ private void CopyDirectory(string oldPath, string newPath, string subpath, bool
171
175
172
176
if ( Path . GetExtension ( file ) . Equals ( ".cs" ) || Path . GetExtension ( file ) . Equals ( ".uxml" ) )
173
177
{
174
- var lines = new List < string > ( ) ;
175
- lines . AddRange ( File . ReadAllLines ( file ) ) ;
176
- int i = 0 ;
177
- while ( i < lines . Count && ! keepComments )
178
- {
179
- int index = lines [ i ] . IndexOf ( "//" , StringComparison . Ordinal ) ;
180
- if ( index != - 1 )
181
- {
182
- if ( ! string . IsNullOrEmpty ( lines [ i ] . Substring ( 0 , index ) . Trim ( ) ) )
183
- {
184
- lines [ i ] = lines [ i ] . Substring ( 0 , index ) ;
185
- i ++ ;
186
- }
187
- else
188
- {
189
- lines . RemoveAt ( i ) ;
190
- }
191
- }
192
- else
193
- {
194
- i ++ ;
195
- }
196
- }
197
-
198
- string text = string . Join ( System . Environment . NewLine , lines ) ;
178
+ var lines = new List < string > ( File . ReadAllLines ( file ) ) ;
179
+ var newLines = lines . Where ( line => ! line . Trim ( ) . StartsWith ( "//" ) ) . ToList ( ) ;
180
+ string text = string . Join ( System . Environment . NewLine , newLines ) ;
199
181
200
182
text = text . Replace ( NAMESPACE , _namespaceField . value + ".ModularShaderSystem" ) ;
201
183
0 commit comments