using XGame.Framework.Asset.Addressable;
using UnityEditor;
using UnityEngine;

namespace XGame.Editor.Asset
{
    [CustomEditor(typeof(AddressableInfosSo), false)]
    public class AddressableInfosSoInspector : UnityEditor.Editor
    {
        private SerializedProperty m_Script;

        private AddressableInfosSoEditor manifestEditor;
        //private AddressableAssetInfoManifest manifest;
        ////private List<AddressableAssetInfo> assetInfos;
        //private AddressableAssetFold asssetFold;

        private void OnEnable()
        {
            m_Script = serializedObject.FindProperty("m_Script");
            var manifest = serializedObject.targetObject as AddressableInfosSo;
            manifestEditor = new AddressableInfosSoEditor(manifest);
        }

        private void OnDisable()
        {
            manifestEditor?.Close();
        }

        public override void OnInspectorGUI()
        {
            //base.OnInspectorGUI();
            serializedObject.Update();

            //展示区域，禁止操作
            EditorGUI.BeginDisabledGroup(true);
            EditorGUILayout.PropertyField(m_Script);
            GUILayout.Space(10);
            EditorGUI.EndDisabledGroup();

            manifestEditor?.OnGUI();

        }
    }

}

