Merge pull request #28 from wqaetly/ForPr

feat:SVC搜集工作支持在CI上进行
pull/31/head
何冠峰 2022-07-27 10:11:41 +08:00 committed by GitHub
commit 78f81ea335
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 9 deletions

View File

@ -213,6 +213,11 @@ namespace YooAsset.Editor
public static void FocusUnitySceneWindow()
{
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()
{

View File

@ -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()