1
This commit is contained in:
74
Src/UnityEditor/AssetCacheDefaultWindow.cs
Normal file
74
Src/UnityEditor/AssetCacheDefaultWindow.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace BITKit.GameEditor
|
||||
{
|
||||
public class AssetCacheDefaultWindow : EditorWindow
|
||||
{
|
||||
[MenuItem("Tools/AssetCache/DefaultWindow")]
|
||||
public static void Open()
|
||||
{
|
||||
var window = GetWindow<AssetCacheDefaultWindow>();
|
||||
window.Show();
|
||||
}
|
||||
private void OnEnable()
|
||||
{
|
||||
Rebuild();
|
||||
}
|
||||
|
||||
private void Rebuild()
|
||||
{
|
||||
rootVisualElement.Clear();
|
||||
var obj =AssetDatabase.LoadAssetAtPath<AssetCacheScriptableObject>("Assets/Artists/Configs/Asset Cache.asset");
|
||||
if (obj is null)
|
||||
{
|
||||
rootVisualElement.Create<Label>().text = "未配置默认的Asset Cache";
|
||||
var button = rootVisualElement.Create<Button>();
|
||||
button.text = "重新载入";
|
||||
//button.clicked += Rebuild;
|
||||
return;
|
||||
}
|
||||
|
||||
rootVisualElement.Bind(new SerializedObject(obj));
|
||||
//BITInspectorExtensions.FillDefaultInspector(rootVisualElement,new SerializedObject(obj),true);
|
||||
|
||||
var rebuildButton = rootVisualElement.Create<Button>();
|
||||
rebuildButton.text = "Rebuild";
|
||||
rebuildButton.clicked += Rebuild;
|
||||
|
||||
var scroll = rootVisualElement.Create<ScrollView>();
|
||||
scroll.style.flexGrow = 1;
|
||||
|
||||
var defaultList = scroll.Create<Foldout>();
|
||||
defaultList.text = "Default";
|
||||
foreach (var x in obj.Assets)
|
||||
{
|
||||
var field = defaultList.Create<ObjectField>();
|
||||
//field.label = x.name;
|
||||
field.style.opacity = 1;
|
||||
field.value = x;
|
||||
field.SetEnabled(false);
|
||||
}
|
||||
|
||||
foreach (var folder in obj.Folders)
|
||||
{
|
||||
var foldout = scroll.Create<Foldout>();
|
||||
foldout.text = folder.Key;
|
||||
foreach (var x in folder.Value)
|
||||
{
|
||||
var field = foldout.Create<ObjectField>();
|
||||
//field.label = x.name;
|
||||
field.style.opacity = 1;
|
||||
field.value = x;
|
||||
field.SetEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user