feat:SVC搜集工作支持在CI上进行

pull/28/head
NKG丶MadLife 2022-07-27 00:17:23 +08:00
parent 7f41ba9a3c
commit 17fab5ad61
2 changed files with 18 additions and 9 deletions

View File

@ -214,6 +214,11 @@ namespace YooAsset.Editor
{ {
EditorWindow.FocusWindowIfItsOpen<SceneView>(); EditorWindow.FocusWindowIfItsOpen<SceneView>();
} }
public static void CloseUnityGameWindow()
{
System.Type T = Assembly.Load("UnityEditor").GetType("UnityEditor.GameView");
EditorWindow.GetWindow(T, false, "GameView", true).Close();
}
public static void FocusUnityGameWindow() public static void FocusUnityGameWindow()
{ {
System.Type T = Assembly.Load("UnityEditor").GetType("UnityEditor.GameView"); System.Type T = Assembly.Load("UnityEditor").GetType("UnityEditor.GameView");

View File

@ -1,4 +1,4 @@
using System.Collections; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
@ -6,21 +6,18 @@ using System.IO;
using UnityEngine; using UnityEngine;
using UnityEditor; using UnityEditor;
using UnityEditor.SceneManagement; using UnityEditor.SceneManagement;
using Debug = UnityEngine.Debug;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[InitializeOnLoad]
public static class ShaderVariantCollector public static class ShaderVariantCollector
{ {
private const float WaitMilliseconds = 1000f; private const float WaitMilliseconds = 1000f;
private static string _saveFilePath; private static string _saveFilePath;
private static bool _isStarted = false; private static bool _isStarted = false;
private static readonly Stopwatch _elapsedTime = new Stopwatch(); private static readonly Stopwatch _elapsedTime = new Stopwatch();
public static Action OnCompletedCallback;
static ShaderVariantCollector()
{
EditorApplication.update += EditorUpdate;
}
private static void EditorUpdate() private static void EditorUpdate()
{ {
// 注意:一定要延迟保存才会起效 // 注意:一定要延迟保存才会起效
@ -28,14 +25,21 @@ namespace YooAsset.Editor
{ {
_isStarted = false; _isStarted = false;
_elapsedTime.Stop(); _elapsedTime.Stop();
EditorApplication.update -= EditorUpdate;
// 保存结果 // 保存结果
SaveCurrentShaderVariantCollection(); SaveCurrentShaderVariantCollection();
// 创建说明文件 // 创建说明文件
CreateReadme(); CreateReadme();
Debug.Log($"搜集SVC完毕");
OnCompletedCallback?.Invoke();
} }
} }
private static void CreateReadme() private static void CreateReadme()
{ {
AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate); AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
@ -59,6 +63,8 @@ namespace YooAsset.Editor
{ {
if (_isStarted) if (_isStarted)
return; return;
EditorApplication.update += EditorUpdate;
if (Path.HasExtension(saveFilePath) == false) if (Path.HasExtension(saveFilePath) == false)
saveFilePath = $"{saveFilePath}.shadervariants"; saveFilePath = $"{saveFilePath}.shadervariants";
@ -83,8 +89,6 @@ namespace YooAsset.Editor
_isStarted = true; _isStarted = true;
_elapsedTime.Reset(); _elapsedTime.Reset();
_elapsedTime.Start(); _elapsedTime.Start();
UnityEngine.Debug.LogWarning("已经启动着色器变种收集工作,该工具只支持在编辑器下人工操作!");
} }
private static void CreateTemperScene() private static void CreateTemperScene()