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 { public override VisualElement CreateInspectorGUI() { root.root.Clear(); if (agent.IsEditable) { return base.CreateInspectorGUI(); } var toggle = root.Create(); toggle.bindingPath = "isEditable"; toggle.label = "Edit"; toggle.RegisterValueChangedCallback(x => CreateInspectorGUI()); foreach (var x in agent.Assets) { var field = root.Create(); //field.label = x.name; field.style.opacity = 1; field.value = x; field.SetEnabled(false); } return root; } } #endif }