using XGame.Editor.Asset;
using UnityEditor;
using UnityEngine;
using UnityToolbarExtender;

[InitializeOnLoad]
class CollectAddressNavigation : INavigation
{
    public int Order => 0;

    static CollectAddressNavigation()
    {
        ToolbarExtender.AddToRight(new CollectAddressNavigation());
    }

    public void OnGUI()
    {
        EditorGUI.BeginDisabledGroup(Application.isPlaying);

        if (GUILayout.Button(new GUIContent("收集资源", "重新收集并生成Addressable Assets清单"), ToolbarStyles.apiButtonStyle))
            AddressableBuildTask.GenManifest();

        EditorGUILayout.Space(20);

        EditorGUI.EndDisabledGroup();
    }
    static class ToolbarStyles
    {
        public static readonly GUIStyle apiButtonStyle;

        static ToolbarStyles()
        {
            apiButtonStyle = new GUIStyle("Command")
            {
                fixedWidth = 80,
                fontSize = 13,
                alignment = TextAnchor.MiddleCenter,
                imagePosition = ImagePosition.ImageAbove,
                fontStyle = FontStyle.Bold
            };
        }
    }
}
