AddressableAssetsWindow.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using XGame.Framework.Asset.Addressable;
  2. using UnityEditor;
  3. using UnityEngine;
  4. namespace XGame.Editor.Asset
  5. {
  6. public class AddressableAssetsWindow : EditorWindow
  7. {
  8. [MenuItem("Build/CollectAddressableAssets", priority = 20)]
  9. private static void CreateWindow()
  10. {
  11. (new AddressableBuildTask()).Run();
  12. var window = EditorWindow.GetWindow<AddressableAssetsWindow>(true, "AddressableAssetsWindow");
  13. window.Show();
  14. }
  15. private string[] labels = { "项目资源", "内置资源", "测试资源" };
  16. private int selected = 0;
  17. private AddressableInfoManifestTab[] manifestTabs;
  18. private void OnEnable()
  19. {
  20. manifestTabs = new AddressableInfoManifestTab[3];
  21. manifestTabs[0] = new AddressableInfoManifestTab(AddressableClassify.Product);
  22. manifestTabs[1] = new AddressableInfoManifestTab(AddressableClassify.BuiltIn);
  23. manifestTabs[2] = new AddressableInfoManifestTab(AddressableClassify.Tests);
  24. }
  25. private void OnDisable()
  26. {
  27. if (manifestTabs != null)
  28. {
  29. foreach (var manifest in manifestTabs)
  30. {
  31. manifest?.Close();
  32. }
  33. }
  34. }
  35. private Vector2 scrollPosition;
  36. private void OnGUI()
  37. {
  38. int lastSelected = selected;
  39. selected = GUILayout.Toolbar(selected, labels, "LargeButton", GUILayout.Width(500));
  40. if (manifestTabs != null)
  41. {
  42. manifestTabs[selected].OnGUI();
  43. }
  44. }
  45. }
  46. }