AlicizaX/Client/Assets/Scripts/Editor/Build/BuildWindow/AdvancedBuildWindow.cs

64 lines
1.5 KiB
C#
Raw Normal View History

2025-03-04 18:40:14 +08:00
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEditor.Build.Reporting;
using UnityEngine;
using YooAsset;
using YooAsset.Editor;
public class AdvancedBuildWindow : EditorWindow
{
private Dictionary<string, EditorWindowTabBase> _tabs = new();
private int _selectedTab = -1;
private string[] _tabLabels;
private Vector2 _scrollPosition;
private EditorWindowTabBase showTab;
public static void ShowWindow()
{
GetWindow<AdvancedBuildWindow>("Build Window", true);
}
private void CreateGUI()
{
_tabs.Add("AB包构建", new AssetBundleBuildTab());
_tabs.Add("整包构建", new AppBuildTab());
_tabLabels = _tabs.Keys.ToArray();
}
private void OnDisable()
{
if (showTab != null)
{
showTab.OnDisable();
}
}
private void OnGUI()
{
var selectedTab = GUILayout.Toolbar(_selectedTab, _tabLabels);
if (selectedTab != _selectedTab)
{
_selectedTab = selectedTab;
if (showTab != null)
{
showTab.OnDisable();
}
string tabKey = _tabLabels[_selectedTab];
_tabs.TryGetValue(tabKey, out showTab);
showTab.OnEnable();
}
_scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition);
{
if (showTab != null) showTab.OnGUI();
}
EditorGUILayout.EndScrollView();
}
}