1
1
#if UNITY_EDITOR
2
2
3
- using System . IO ;
3
+ using System . Collections . Generic ;
4
4
using UnityEditor ;
5
5
6
6
namespace SatorImaging . UnitySourceGenerator
7
7
{
8
- static class EditorExtension
8
+ public static class EditorExtension
9
9
{
10
10
const string ROOT_MENU = @"Assets/Unity Source Generator/" ;
11
11
const string TEMPLATE_PATH = @"Packages/com.sator-imaging.alt-source-generator/Template/Template_" ;
@@ -16,16 +16,23 @@ static class EditorExtension
16
16
[ MenuItem ( ROOT_MENU + "Force Generate while Overwriting Disabled" ) ]
17
17
static void ForceGenerateSelectedScripts ( )
18
18
{
19
+ if ( Selection . assetGUIDs == null || Selection . assetGUIDs . Length == 0 )
20
+ return ;
21
+
19
22
// NOTE: when multiple files selected, first import event initialize C# environment.
20
23
// --> https://docs.unity3d.com/2021.3/Documentation/Manual/DomainReloading.html
21
- // need to use USGEngine.ProcessFile() instead.
24
+ // so that need to process files at once.
25
+ var filePathList = new List < string > ( Selection . assetGUIDs . Length ) ;
26
+
22
27
foreach ( var guid in Selection . assetGUIDs )
23
28
{
24
29
var path = AssetDatabase . GUIDToAssetPath ( guid ) ;
25
- //USGEngine.IgnoreOverwriteSettingOnAttribute = true;
26
- //USGEngine.ProcessFile(path);
27
- USGUtility . ForceGenerateByName ( Path . GetFileNameWithoutExtension ( path ) , false ) ;
30
+ if ( AssetDatabase . LoadAssetAtPath < MonoScript > ( path ) is not MonoScript )
31
+ continue ;
32
+
33
+ filePathList . Add ( path ) ;
28
34
}
35
+ USGEngine . Process ( filePathList . ToArray ( ) , true ) ;
29
36
}
30
37
31
38
0 commit comments