mirror of https://github.com/tuyoogame/YooAsset
parent
4e4da4440b
commit
fd282d96d1
|
@ -1,7 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEditor;
|
using UnityEditor;
|
||||||
|
|
||||||
|
@ -20,6 +19,11 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 配置数据是否被修改
|
||||||
|
/// </summary>
|
||||||
|
public static bool IsDirty { set; get; } = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载配置文件
|
/// 加载配置文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -35,6 +39,7 @@ namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
if (Setting != null)
|
if (Setting != null)
|
||||||
{
|
{
|
||||||
|
IsDirty = false;
|
||||||
EditorUtility.SetDirty(Setting);
|
EditorUtility.SetDirty(Setting);
|
||||||
AssetDatabase.SaveAssets();
|
AssetDatabase.SaveAssets();
|
||||||
Debug.Log($"{nameof(ShaderVariantCollectorSetting)}.asset is saved!");
|
Debug.Log($"{nameof(ShaderVariantCollectorSetting)}.asset is saved!");
|
||||||
|
|
|
@ -20,6 +20,7 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
private List<string> _packageNames;
|
private List<string> _packageNames;
|
||||||
|
|
||||||
|
private Button _saveButton;
|
||||||
private Button _collectButton;
|
private Button _collectButton;
|
||||||
private TextField _collectOutputField;
|
private TextField _collectOutputField;
|
||||||
private Label _currentShaderCountField;
|
private Label _currentShaderCountField;
|
||||||
|
@ -40,6 +41,10 @@ namespace YooAsset.Editor
|
||||||
|
|
||||||
visualAsset.CloneTree(root);
|
visualAsset.CloneTree(root);
|
||||||
|
|
||||||
|
// 配置保存按钮
|
||||||
|
_saveButton = root.Q<Button>("SaveButton");
|
||||||
|
_saveButton.clicked += SaveBtn_clicked;
|
||||||
|
|
||||||
// 包裹名称列表
|
// 包裹名称列表
|
||||||
_packageNames = GetBuildPackageNames();
|
_packageNames = GetBuildPackageNames();
|
||||||
|
|
||||||
|
@ -48,6 +53,7 @@ namespace YooAsset.Editor
|
||||||
_collectOutputField.SetValueWithoutNotify(ShaderVariantCollectorSettingData.Setting.SavePath);
|
_collectOutputField.SetValueWithoutNotify(ShaderVariantCollectorSettingData.Setting.SavePath);
|
||||||
_collectOutputField.RegisterValueChangedCallback(evt =>
|
_collectOutputField.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
|
ShaderVariantCollectorSettingData.IsDirty = true;
|
||||||
ShaderVariantCollectorSettingData.Setting.SavePath = _collectOutputField.value;
|
ShaderVariantCollectorSettingData.Setting.SavePath = _collectOutputField.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -61,6 +67,7 @@ namespace YooAsset.Editor
|
||||||
_packageField.style.width = 350;
|
_packageField.style.width = 350;
|
||||||
_packageField.RegisterValueChangedCallback(evt =>
|
_packageField.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
|
ShaderVariantCollectorSettingData.IsDirty = true;
|
||||||
ShaderVariantCollectorSettingData.Setting.CollectPackage = _packageField.value;
|
ShaderVariantCollectorSettingData.Setting.CollectPackage = _packageField.value;
|
||||||
});
|
});
|
||||||
packageContainer.Add(_packageField);
|
packageContainer.Add(_packageField);
|
||||||
|
@ -80,12 +87,14 @@ namespace YooAsset.Editor
|
||||||
_processCapacitySlider.label = $"Capacity ({_processCapacitySlider.value})";
|
_processCapacitySlider.label = $"Capacity ({_processCapacitySlider.value})";
|
||||||
_processCapacitySlider.RegisterValueChangedCallback(evt =>
|
_processCapacitySlider.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
|
ShaderVariantCollectorSettingData.IsDirty = true;
|
||||||
ShaderVariantCollectorSettingData.Setting.ProcessCapacity = _processCapacitySlider.value;
|
ShaderVariantCollectorSettingData.Setting.ProcessCapacity = _processCapacitySlider.value;
|
||||||
_processCapacitySlider.label = $"Capacity ({_processCapacitySlider.value})";
|
_processCapacitySlider.label = $"Capacity ({_processCapacitySlider.value})";
|
||||||
});
|
});
|
||||||
#else
|
#else
|
||||||
_processCapacitySlider.RegisterValueChangedCallback(evt =>
|
_processCapacitySlider.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
|
ShaderVariantCollectorSettingData.IsDirty = true;
|
||||||
ShaderVariantCollectorSettingData.Setting.ProcessCapacity = _processCapacitySlider.value;
|
ShaderVariantCollectorSettingData.Setting.ProcessCapacity = _processCapacitySlider.value;
|
||||||
});
|
});
|
||||||
#endif
|
#endif
|
||||||
|
@ -102,8 +111,27 @@ namespace YooAsset.Editor
|
||||||
Debug.LogError(e.ToString());
|
Debug.LogError(e.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void OnDestroy()
|
||||||
|
{
|
||||||
|
if (ShaderVariantCollectorSettingData.IsDirty)
|
||||||
|
ShaderVariantCollectorSettingData.SaveFile();
|
||||||
|
}
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
|
if (_saveButton != null)
|
||||||
|
{
|
||||||
|
if (ShaderVariantCollectorSettingData.IsDirty)
|
||||||
|
{
|
||||||
|
if (_saveButton.enabledSelf == false)
|
||||||
|
_saveButton.SetEnabled(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_saveButton.enabledSelf)
|
||||||
|
_saveButton.SetEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_currentShaderCountField != null)
|
if (_currentShaderCountField != null)
|
||||||
{
|
{
|
||||||
int currentShaderCount = ShaderVariantCollectionHelper.GetCurrentShaderVariantCollectionShaderCount();
|
int currentShaderCount = ShaderVariantCollectionHelper.GetCurrentShaderVariantCollectionShaderCount();
|
||||||
|
@ -117,6 +145,10 @@ namespace YooAsset.Editor
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SaveBtn_clicked()
|
||||||
|
{
|
||||||
|
ShaderVariantCollectorSettingData.SaveFile();
|
||||||
|
}
|
||||||
private void CollectButton_clicked()
|
private void CollectButton_clicked()
|
||||||
{
|
{
|
||||||
string savePath = ShaderVariantCollectorSettingData.Setting.SavePath;
|
string savePath = ShaderVariantCollectorSettingData.Setting.SavePath;
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements">
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||||
|
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row-reverse;">
|
||||||
|
<ui:Button text="Save" display-tooltip-when-elided="true" name="SaveButton" style="background-color: rgb(40, 106, 42);" />
|
||||||
|
</uie:Toolbar>
|
||||||
<ui:VisualElement name="CollectContainer">
|
<ui:VisualElement name="CollectContainer">
|
||||||
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row-reverse;" />
|
|
||||||
<ui:TextField picking-mode="Ignore" label="文件保存路径" name="CollectOutput" style="height: 22px;" />
|
<ui:TextField picking-mode="Ignore" label="文件保存路径" name="CollectOutput" style="height: 22px;" />
|
||||||
<ui:VisualElement name="PackageContainer" style="height: 24px;" />
|
<ui:VisualElement name="PackageContainer" style="height: 24px;" />
|
||||||
<ui:Label text="Current Shader Count" display-tooltip-when-elided="true" name="CurrentShaderCount" style="height: 20px; padding-left: 4px;" />
|
<ui:Label text="Current Shader Count" display-tooltip-when-elided="true" name="CurrentShaderCount" style="height: 20px; padding-left: 4px;" />
|
||||||
|
|
Loading…
Reference in New Issue