using System;
using System.Collections.Generic;
using System.IO;
using EditorFramework;
using Sirenix.OdinInspector;
using UnityEditor;

namespace Stary.Evo.Editor
{
    [Serializable]
    public class CreatDomainEntity
    {
        private List<CreatDomainEntity> domainList;
        
        [HorizontalGroup] [ReadOnly] public string DomainName;
        [ReadOnly]
        public string domainPath;


        public CreatDomainEntity(List<CreatDomainEntity> domainList)
        {
            this.domainList = domainList;
        }
        [HorizontalGroup(Width = 60)]
        [Button("", Icon = SdfIconType.XCircle, IconAlignment = IconAlignment.RightEdge)]
        public void CloseDomain()
        {
            bool isOk = EditorUtility.DisplayDialog("提示", "是否删除此Domain", "是", "否");
            if (isOk)
            {
                BuildAssetWindow.RemoveBuildAssetWindow();
                EditorFrameworkUtils.DeleteAllChild(domainPath, FileAttributes.Normal);
                domainList.Clear();
                AssetDatabase.Refresh();
                AssetDatabase.SaveAssets();
            }
        }
    }
}