From 17fab5ad6187b999c5b3048f28907ae6c23222f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?NKG=E4=B8=B6MadLife?= <1778139321@qq.com> Date: Wed, 27 Jul 2022 00:17:23 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat=EF=BC=9ASVC=E6=90=9C=E9=9B=86=E5=B7=A5?= =?UTF-8?q?=E4=BD=9C=E6=94=AF=E6=8C=81=E5=9C=A8CI=E4=B8=8A=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/YooAsset/Editor/EditorTools.cs | 5 +++++ .../ShaderVariantCollector.cs | 22 +++++++++++-------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Assets/YooAsset/Editor/EditorTools.cs b/Assets/YooAsset/Editor/EditorTools.cs index fc1effd..f475b1c 100644 --- a/Assets/YooAsset/Editor/EditorTools.cs +++ b/Assets/YooAsset/Editor/EditorTools.cs @@ -214,6 +214,11 @@ namespace YooAsset.Editor { EditorWindow.FocusWindowIfItsOpen(); } + public static void CloseUnityGameWindow() + { + System.Type T = Assembly.Load("UnityEditor").GetType("UnityEditor.GameView"); + EditorWindow.GetWindow(T, false, "GameView", true).Close(); + } public static void FocusUnityGameWindow() { System.Type T = Assembly.Load("UnityEditor").GetType("UnityEditor.GameView"); diff --git a/Assets/YooAsset/Editor/ShaderVariantCollector/ShaderVariantCollector.cs b/Assets/YooAsset/Editor/ShaderVariantCollector/ShaderVariantCollector.cs index d895e32..18e5301 100644 --- a/Assets/YooAsset/Editor/ShaderVariantCollector/ShaderVariantCollector.cs +++ b/Assets/YooAsset/Editor/ShaderVariantCollector/ShaderVariantCollector.cs @@ -1,4 +1,4 @@ -using System.Collections; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; @@ -6,21 +6,18 @@ using System.IO; using UnityEngine; using UnityEditor; using UnityEditor.SceneManagement; +using Debug = UnityEngine.Debug; namespace YooAsset.Editor { - [InitializeOnLoad] public static class ShaderVariantCollector { private const float WaitMilliseconds = 1000f; private static string _saveFilePath; private static bool _isStarted = false; private static readonly Stopwatch _elapsedTime = new Stopwatch(); + public static Action OnCompletedCallback; - static ShaderVariantCollector() - { - EditorApplication.update += EditorUpdate; - } private static void EditorUpdate() { // 注意:一定要延迟保存才会起效 @@ -28,14 +25,21 @@ namespace YooAsset.Editor { _isStarted = false; _elapsedTime.Stop(); - + + EditorApplication.update -= EditorUpdate; + // 保存结果 SaveCurrentShaderVariantCollection(); // 创建说明文件 CreateReadme(); + + Debug.Log($"搜集SVC完毕"); + + OnCompletedCallback?.Invoke(); } } + private static void CreateReadme() { AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); @@ -59,6 +63,8 @@ namespace YooAsset.Editor { if (_isStarted) return; + + EditorApplication.update += EditorUpdate; if (Path.HasExtension(saveFilePath) == false) saveFilePath = $"{saveFilePath}.shadervariants"; @@ -83,8 +89,6 @@ namespace YooAsset.Editor _isStarted = true; _elapsedTime.Reset(); _elapsedTime.Start(); - - UnityEngine.Debug.LogWarning("已经启动着色器变种收集工作,该工具只支持在编辑器下人工操作!"); } private static void CreateTemperScene() From 21f350a84e8008cd2f4276c5ad80a40c501fde45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?NKG=E4=B8=B6MadLife?= <1778139321@qq.com> Date: Wed, 27 Jul 2022 00:19:23 +0800 Subject: [PATCH 2/2] =?UTF-8?q?chore=EF=BC=9A=E8=B0=83=E6=95=B4=E7=BC=A9?= =?UTF-8?q?=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/YooAsset/Editor/EditorTools.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Assets/YooAsset/Editor/EditorTools.cs b/Assets/YooAsset/Editor/EditorTools.cs index f475b1c..f91c041 100644 --- a/Assets/YooAsset/Editor/EditorTools.cs +++ b/Assets/YooAsset/Editor/EditorTools.cs @@ -213,12 +213,12 @@ namespace YooAsset.Editor public static void FocusUnitySceneWindow() { EditorWindow.FocusWindowIfItsOpen(); + } + public static void CloseUnityGameWindow() + { + System.Type T = Assembly.Load("UnityEditor").GetType("UnityEditor.GameView"); + EditorWindow.GetWindow(T, false, "GameView", true).Close(); } - public static void CloseUnityGameWindow() - { - System.Type T = Assembly.Load("UnityEditor").GetType("UnityEditor.GameView"); - EditorWindow.GetWindow(T, false, "GameView", true).Close(); - } public static void FocusUnityGameWindow() { System.Type T = Assembly.Load("UnityEditor").GetType("UnityEditor.GameView");