mirror of https://github.com/tuyoogame/YooAsset
parent
9f1eaf4a62
commit
501765eaa7
|
@ -15,7 +15,15 @@ namespace YooAsset.Editor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string AssetBundleGrouperSettingFilePath = "Assets/YooAssetSetting/AssetBundleGrouperSetting.asset";
|
public const string AssetBundleGrouperSettingFilePath = "Assets/YooAssetSetting/AssetBundleGrouperSetting.asset";
|
||||||
|
|
||||||
public static readonly Type[] DockedWindowTypes = { typeof(AssetBundleBuilderWindow), typeof(AssetBundleGrouperWindow), typeof(AssetBundleDebuggerWindow), typeof(AssetBundleReporterWindow) , typeof(ShaderVariantCollectionWindow)};
|
/// <summary>
|
||||||
|
/// 着色器变种收集工具的配置文件存储路径
|
||||||
|
/// </summary>
|
||||||
|
public const string ShaderVariantCollectorSettingFilePath = "Assets/YooAssetSetting/ShaderVariantCollectorSetting.asset";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 停靠窗口类型集合
|
||||||
|
/// </summary>
|
||||||
|
public static readonly Type[] DockedWindowTypes = { typeof(AssetBundleBuilderWindow), typeof(AssetBundleGrouperWindow), typeof(AssetBundleDebuggerWindow), typeof(AssetBundleReporterWindow)};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class ShaderVariantCollectorSetting : ScriptableObject
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 文件存储路径
|
||||||
|
/// </summary>
|
||||||
|
public string SavePath = "Assets/MyShaderVariants.shadervariants";
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 44454e58a49818040a1aef5799e71b30
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,58 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class ShaderVariantCollectorSettingData
|
||||||
|
{
|
||||||
|
private static ShaderVariantCollectorSetting _setting = null;
|
||||||
|
public static ShaderVariantCollectorSetting Setting
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_setting == null)
|
||||||
|
LoadSettingData();
|
||||||
|
return _setting;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载配置文件
|
||||||
|
/// </summary>
|
||||||
|
private static void LoadSettingData()
|
||||||
|
{
|
||||||
|
// 加载配置文件
|
||||||
|
_setting = AssetDatabase.LoadAssetAtPath<ShaderVariantCollectorSetting>(EditorDefine.ShaderVariantCollectorSettingFilePath);
|
||||||
|
if (_setting == null)
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"Create new {nameof(ShaderVariantCollectorSetting)}.asset : {EditorDefine.ShaderVariantCollectorSettingFilePath}");
|
||||||
|
_setting = ScriptableObject.CreateInstance<ShaderVariantCollectorSetting>();
|
||||||
|
EditorTools.CreateFileDirectory(EditorDefine.ShaderVariantCollectorSettingFilePath);
|
||||||
|
AssetDatabase.CreateAsset(Setting, EditorDefine.ShaderVariantCollectorSettingFilePath);
|
||||||
|
AssetDatabase.SaveAssets();
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Log($"Load {nameof(ShaderVariantCollectorSetting)}.asset ok");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 存储文件
|
||||||
|
/// </summary>
|
||||||
|
public static void SaveFile()
|
||||||
|
{
|
||||||
|
if (Setting != null)
|
||||||
|
{
|
||||||
|
EditorUtility.SetDirty(Setting);
|
||||||
|
AssetDatabase.SaveAssets();
|
||||||
|
Debug.Log($"{nameof(ShaderVariantCollectorSetting)}.asset is saved!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b3043e89ff35bd346b268c0e8d460067
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -12,19 +12,18 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
if (_thisInstance == null)
|
if (_thisInstance == null)
|
||||||
{
|
{
|
||||||
_thisInstance = GetWindow<ShaderVariantCollectionWindow>("ShaderVariant Collector", true, EditorDefine.DockedWindowTypes);
|
_thisInstance = GetWindow<ShaderVariantCollectionWindow>("着色器变种收集工具");
|
||||||
_thisInstance.minSize = new Vector2(800, 600);
|
_thisInstance.minSize = new Vector2(800, 600);
|
||||||
}
|
}
|
||||||
_thisInstance.Show();
|
_thisInstance.Show();
|
||||||
}
|
}
|
||||||
|
|
||||||
private string _saveFilePath = "Assets/MyShaderVariants.shadervariants";
|
|
||||||
private ShaderVariantCollection _selectSVC;
|
private ShaderVariantCollection _selectSVC;
|
||||||
|
|
||||||
private void OnGUI()
|
private void OnGUI()
|
||||||
{
|
{
|
||||||
EditorGUILayout.Space();
|
EditorGUILayout.Space();
|
||||||
_saveFilePath = EditorGUILayout.TextField("收集文件保存路径", _saveFilePath);
|
ShaderVariantCollectorSettingData.Setting.SavePath = EditorGUILayout.TextField("收集文件保存路径", ShaderVariantCollectorSettingData.Setting.SavePath);
|
||||||
|
|
||||||
int currentShaderCount = ShaderVariantCollector.GetCurrentShaderVariantCollectionShaderCount();
|
int currentShaderCount = ShaderVariantCollector.GetCurrentShaderVariantCollectionShaderCount();
|
||||||
int currentVariantCount = ShaderVariantCollector.GetCurrentShaderVariantCollectionVariantCount();
|
int currentVariantCount = ShaderVariantCollector.GetCurrentShaderVariantCollectionVariantCount();
|
||||||
|
@ -35,7 +34,7 @@ namespace YooAsset.Editor
|
||||||
EditorGUILayout.Space();
|
EditorGUILayout.Space();
|
||||||
if (GUILayout.Button("搜集变种", GUILayout.MaxWidth(80)))
|
if (GUILayout.Button("搜集变种", GUILayout.MaxWidth(80)))
|
||||||
{
|
{
|
||||||
ShaderVariantCollector.Run(_saveFilePath);
|
ShaderVariantCollector.Run(ShaderVariantCollectorSettingData.Setting.SavePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询
|
// 查询
|
||||||
|
@ -54,5 +53,9 @@ namespace YooAsset.Editor
|
||||||
EditorGUILayout.LabelField($"VariantCount : {_selectSVC.variantCount}");
|
EditorGUILayout.LabelField($"VariantCount : {_selectSVC.variantCount}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void OnDestroy()
|
||||||
|
{
|
||||||
|
ShaderVariantCollectorSettingData.SaveFile();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue