CollectAddressNavigation.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using XGame.Editor.Asset;
  2. using UnityEditor;
  3. using UnityEngine;
  4. using UnityToolbarExtender;
  5. [InitializeOnLoad]
  6. class CollectAddressNavigation : INavigation
  7. {
  8. public int Order => 0;
  9. static CollectAddressNavigation()
  10. {
  11. ToolbarExtender.AddToRight(new CollectAddressNavigation());
  12. }
  13. public void OnGUI()
  14. {
  15. EditorGUI.BeginDisabledGroup(Application.isPlaying);
  16. if (GUILayout.Button(new GUIContent("收集资源", "重新收集并生成Addressable Assets清单"), ToolbarStyles.apiButtonStyle))
  17. AddressableBuildTask.GenManifest();
  18. EditorGUILayout.Space(20);
  19. EditorGUI.EndDisabledGroup();
  20. }
  21. static class ToolbarStyles
  22. {
  23. public static readonly GUIStyle apiButtonStyle;
  24. static ToolbarStyles()
  25. {
  26. apiButtonStyle = new GUIStyle("Command")
  27. {
  28. fixedWidth = 80,
  29. fontSize = 13,
  30. alignment = TextAnchor.MiddleCenter,
  31. imagePosition = ImagePosition.ImageAbove,
  32. fontStyle = FontStyle.Bold
  33. };
  34. }
  35. }
  36. }