Skip to content

Commit 9abed46

Browse files
Merge pull request #1 from sator-imaging/active/v3
Active/v3
2 parents d55bd2c + 20422cb commit 9abed46

24 files changed

+760
-520
lines changed

CHANGELOG.md

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,33 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88

9-
## [Unreleased]
9+
## [Unreleased](https://github.com/sator-imaging/Unity-AltSourceGenerator)
1010

11+
- nothing yet
12+
13+
14+
15+
## [3.0.0](https://github.com/sator-imaging/Unity-AltSourceGenerator/releases/tag/v3.0.0)
16+
17+
18+
### API Changes 😉
19+
20+
#### Features works only on Unity Editor
21+
22+
classes moved to `Editor` namespace.
23+
24+
#### `USGEngine.ProcessFile()` will be removed
25+
26+
use `USGUtility.ForceGenerateByType(typeof(...))` instead.
27+
28+
#### `USGUtility.**ByName()` will be removed
29+
30+
methods still exist but obsolete. use `USGUtility.**ByType()` instead.
31+
32+
33+
34+
## [2.0.0](https://github.com/sator-imaging/Unity-AltSourceGenerator/releases/tag/v2.0.0)
1135

12-
## [2.0.0]()
1336

1437
### Breaking Changes ;-)
1538

@@ -26,7 +49,7 @@ now private. use `ProcessFile(path, *true*)` instead.
2649

2750
`showInProjectPanel` now false by default.
2851

29-
#### usg<T>(params string[] memberNames)
52+
#### usg\<T>(params string[] memberNames)
3053

3154
`global::` namespace will be added.
3255

Editor/EditorEvent.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Reflection;
55
using UnityEditor;
66

7-
namespace SatorImaging.UnitySourceGenerator
7+
namespace SatorImaging.UnitySourceGenerator.Editor
88
{
99
public static class EditorEvent
1010
{
@@ -24,7 +24,8 @@ internal static void RegisterFocusChangedEvent(bool registerOrRemove)
2424
//https://github.com/Unity-Technologies/UnityCsReference/blob/master/Editor/Mono/EditorApplication.cs#L275
2525
var focusChanged = typeof(EditorApplication).GetField("focusChanged",
2626
BindingFlags.Static | BindingFlags.NonPublic);
27-
if (focusChanged == null) return;
27+
if (focusChanged == null)
28+
return;
2829

2930
// TODO: better cleanup.
3031
// currently, event can be unregistered but it seems empty action runs on focus changed event...?
@@ -50,32 +51,33 @@ internal static void RegisterFocusChangedEvent(bool registerOrRemove)
5051
//Debug.Log($"[USG] Null? {currentAction == null} Method:{currentAction.Method} Target:{currentAction.Target}");
5152

5253
_restoreAutoRefresh = EditorPrefs.GetInt(PREF_AUTO_REFRESH, EditorPrefs.GetInt(PREF_AUTO_REFRESH_OLD, DEFAULT_AUTO_REFRESH));
53-
_restoreDirMonitoring = EditorPrefs.GetBool(PREF_DIR_MONITORING, DEFAULT_DIR_MONITORING);
54+
//_restoreDirMonitoring = EditorPrefs.GetBool(PREF_DIR_MONITORING, DEFAULT_DIR_MONITORING);
5455
}
5556

5657
const bool DEFAULT_DIR_MONITORING = true;
5758
const int DEFAULT_AUTO_REFRESH = 1;
5859
const string PREF_AUTO_REFRESH = "kAutoRefreshMode";
5960
const string PREF_AUTO_REFRESH_OLD = "kAutoRefresh";
60-
const string PREF_DIR_MONITORING = "DirectoryMonitoring";
61-
static bool _restoreDirMonitoring = DEFAULT_DIR_MONITORING;
61+
//const string PREF_DIR_MONITORING = "DirectoryMonitoring";
62+
//static bool _restoreDirMonitoring = DEFAULT_DIR_MONITORING;
6263
static int _restoreAutoRefresh = DEFAULT_AUTO_REFRESH;
6364
static void OnEditorApplicationFocus(bool focus)
6465
{
6566
//https://github.com/Unity-Technologies/UnityCsReference/blob/master/Editor/Mono/PreferencesWindow/AssetPipelinePreferences.cs#L94
6667
if (focus == false)
6768
{
6869
_restoreAutoRefresh = EditorPrefs.GetInt(PREF_AUTO_REFRESH, EditorPrefs.GetInt(PREF_AUTO_REFRESH_OLD, DEFAULT_AUTO_REFRESH));
69-
_restoreDirMonitoring = EditorPrefs.GetBool(PREF_DIR_MONITORING, DEFAULT_DIR_MONITORING);
70+
//_restoreDirMonitoring = EditorPrefs.GetBool(PREF_DIR_MONITORING, DEFAULT_DIR_MONITORING);
71+
7072
//AssetDatabase.DisallowAutoRefresh();
7173
EditorApplication.LockReloadAssemblies();
72-
EditorPrefs.SetBool(PREF_DIR_MONITORING, false);
74+
//EditorPrefs.SetBool(PREF_DIR_MONITORING, false);
7375
EditorPrefs.SetInt(PREF_AUTO_REFRESH, 0);
7476
EditorPrefs.SetInt(PREF_AUTO_REFRESH_OLD, 0);
7577
}
7678
else
7779
{
78-
EditorPrefs.SetBool(PREF_DIR_MONITORING, _restoreDirMonitoring);
80+
//EditorPrefs.SetBool(PREF_DIR_MONITORING, _restoreDirMonitoring);
7981
EditorPrefs.SetInt(PREF_AUTO_REFRESH, _restoreAutoRefresh);
8082
EditorPrefs.SetInt(PREF_AUTO_REFRESH_OLD, _restoreAutoRefresh);
8183

Editor/EditorExtension.cs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#if UNITY_EDITOR
22

3-
using System.IO;
3+
using System.Collections.Generic;
44
using UnityEditor;
55

6-
namespace SatorImaging.UnitySourceGenerator
6+
namespace SatorImaging.UnitySourceGenerator.Editor
77
{
8-
static class EditorExtension
8+
public static class EditorExtension
99
{
1010
const string ROOT_MENU = @"Assets/Unity Source Generator/";
1111
const string TEMPLATE_PATH = @"Packages/com.sator-imaging.alt-source-generator/Template/Template_";
@@ -16,16 +16,23 @@ static class EditorExtension
1616
[MenuItem(ROOT_MENU + "Force Generate while Overwriting Disabled")]
1717
static void ForceGenerateSelectedScripts()
1818
{
19+
if (Selection.assetGUIDs == null || Selection.assetGUIDs.Length == 0)
20+
return;
21+
1922
// NOTE: when multiple files selected, first import event initialize C# environment.
2023
// --> 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+
2227
foreach (var guid in Selection.assetGUIDs)
2328
{
2429
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);
2834
}
35+
USGEngine.Process(filePathList.ToArray(), true);
2936
}
3037

3138

Editor/ProjectSettingsData.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using UnityEngine;
66

77

8-
namespace SatorImaging.UnitySourceGenerator
8+
namespace SatorImaging.UnitySourceGenerator.Editor
99
{
1010
public class ProjectSettingsData : ProjectSettingsSingleton<ProjectSettingsData>
1111
{

0 commit comments

Comments
 (0)