using System;
using Sirenix.OdinInspector;
using UnityEngine;

namespace Stary.Evo.Editor
{
    [Serializable]
    public class BuildAssetEntity
    {
        public BuildAssetEntity(string HorizontalGroupName,string ButtonName ,Action OnClickAction )
        {
            this.HorizontalGroupName = HorizontalGroupName;
            this.ButtonName = ButtonName;
            this.OnClickAction = OnClickAction;
        }


        private Color messageColor = Color.white;
        private string messageText = "点击开始进程！！！！！";
        private bool showInfoBox = true;
        private string HorizontalGroupName;
        private string ButtonName;
        private Action OnClickAction;
        [HorizontalGroup("@ HorizontalGroupName")]
        [Button("@ ButtonName", ButtonSizes.Large)]
        [InfoBox("@ messageText", InfoMessageType.Error, "@ showInfoBox==false")]
        [InfoBox("@ messageText", InfoMessageType.Info, "@ showInfoBox==true")]
        private void CopyDll()
        {
            try
            {
                OnClickAction?.Invoke();
                showInfoBox = true;
                messageColor = Color.green;
                messageText = "进程结束！！！！！";
            }
            catch (Exception e)
            {
                Debug.LogError(e);
                showInfoBox = false;
                messageText =$"进程存在异常，异常信息为：【{e.Message}】" ;
                messageColor = Color.red;
            }
        }

        [HorizontalGroup("@ HorizontalGroupName", Width = 68)]
        [Button(ButtonSizes.Large, Icon = SdfIconType.CheckCircleFill, IconAlignment = IconAlignment.RightEdge,
             ButtonHeight = 68),
         GUIColor("@messageColor")]
        private void CopyDll1()
        {
        }


        public void SetButtonName(string ButtonName)
        {
            this.ButtonName = ButtonName;
        }
    }
}