51 lines
1.1 KiB
C#
51 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
#if UNITY_EDITOR
|
|
using UnityEditor;
|
|
using UnityEditor.UIElements;
|
|
#endif
|
|
using UnityEngine;
|
|
using UnityEngine.UIElements;
|
|
|
|
namespace BITKit.GameEditor
|
|
{
|
|
public class AssetCacheScriptableObject : ScriptableObject
|
|
{
|
|
[SerializeField] private bool isEditable;
|
|
[SerializeField] private Object[] _assets;
|
|
|
|
public bool IsEditable => isEditable;
|
|
public Object[] Assets => _assets;
|
|
}
|
|
#if UNITY_EDITOR
|
|
[CustomEditor(typeof(AssetCacheScriptableObject))]
|
|
public class AssetCacheScriptableObjectEditor : BITInspector<AssetCacheScriptableObject>
|
|
{
|
|
public override VisualElement CreateInspectorGUI()
|
|
{
|
|
root.root.Clear();
|
|
if (agent.IsEditable)
|
|
{
|
|
return base.CreateInspectorGUI();
|
|
}
|
|
|
|
var toggle = root.Create<Toggle>();
|
|
toggle.bindingPath = "isEditable";
|
|
toggle.label = "Edit";
|
|
|
|
toggle.RegisterValueChangedCallback(x => CreateInspectorGUI());
|
|
|
|
foreach (var x in agent.Assets)
|
|
{
|
|
var field = root.Create<ObjectField>();
|
|
//field.label = x.name;
|
|
field.style.opacity = 1;
|
|
field.value = x;
|
|
field.SetEnabled(false);
|
|
}
|
|
return root;
|
|
}
|
|
}
|
|
#endif
|
|
}
|