UI框架开发中

This commit is contained in:
2025-09-29 07:45:07 +08:00
parent 423ad80303
commit 71edbb6088
39 changed files with 1191 additions and 397 deletions

View File

@@ -10,7 +10,7 @@ public class GameStart : MonoBehaviour
{
DontDestroyOnLoad(gameObject);
StartCoroutine(LoadScene());
StartCoroutine(LoadUIManager());
//StartCoroutine(LoadUIManager());
}
IEnumerator LoadScene()
{
@@ -23,17 +23,17 @@ public class GameStart : MonoBehaviour
};
yield return sceneHandle;
}
IEnumerator LoadUIManager()
{
AssetHandle _handle = YooAssets.LoadAssetAsync<GameObject>("UIManager");
_handle.Completed += (handle) =>
{
GameObject go = Instantiate((GameObject)_handle.AssetObject);
DontDestroyOnLoad(go);
Debug.Log(_handle.AssetObject);
};
yield return _handle;
}
//IEnumerator LoadUIManager()
//{
// AssetHandle _handle = YooAssets.LoadAssetAsync<GameObject>("UIManager");
// _handle.Completed += (handle) =>
// {
// GameObject go = Instantiate((GameObject)_handle.AssetObject);
// DontDestroyOnLoad(go);
// Debug.Log(_handle.AssetObject);
// };
// yield return _handle;
//}
IEnumerator LoadNetWorkHUD()
{
AssetHandle _handle = YooAssets.LoadAssetAsync<GameObject>("MyNetWorkHUD");

View File

@@ -36,7 +36,6 @@ public class NetWorkThirdCharacterController : NetworkBehaviour
//if (!isLocalPlayer) return;
framingTransposer = vCam.GetCinemachineComponent<CinemachineFramingTransposer>();
pov = vCam.GetCinemachineComponent<CinemachinePOV>();
UpdateCursorState();
}
void Update()
{
@@ -120,16 +119,16 @@ public class NetWorkThirdCharacterController : NetworkBehaviour
if (!isLocalPlayer) return;
if (context.performed)
{
isCursorLocked = !isCursorLocked;
UpdateCursorState();
if (isCursorLocked)
{
SettingsManager.Instance.CloseSettingWindow();
}
else
{
SettingsManager.Instance.OpenSettingWindow();
}
//isCursorLocked = SettingsManager.Inst.isShow();
//UpdateCursorState();
//if (SettingsManager.Inst.isShow())
//{
// SettingsManager.Inst.CloseSettingWindow();
//}
//else
//{
// SettingsManager.Inst.OpenSettingWindow();
//}
}
}
public void OnAlt(InputAction.CallbackContext context)
@@ -197,6 +196,7 @@ public class NetWorkThirdCharacterController : NetworkBehaviour
{
Debug.Log("OnStartLocalPlayer");
vCam.Priority = 15;
UpdateCursorState();
}
/// <summary>

View File

@@ -115,14 +115,14 @@ public class ThirdCharacterController : MonoBehaviour
{
isCursorLocked = !isCursorLocked;
UpdateCursorState();
if (isCursorLocked)
{
SettingsManager.Instance.CloseSettingWindow();
}
else
{
SettingsManager.Instance.OpenSettingWindow();
}
//if (SettingsManager.Inst.isShow())
//{
// SettingsManager.Inst.CloseSettingWindow();
//}
//else
//{
// SettingsManager.Inst.OpenSettingWindow();
//}
}
}
public void OnFire(InputAction.CallbackContext context)

View File

@@ -1,18 +0,0 @@
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class GeneralPanel : MonoBehaviour
{
[SerializeField] private TMP_InputField serverAddressInput;
private void OnEnable()
{
serverAddressInput.text = SettingsManager.Instance.CurrentSettings.serverAddress;
}
public void OnServerAddressChanged(string value)
{
SettingsManager.Instance.CurrentSettings.serverAddress = value;
}
}

View File

@@ -1,90 +0,0 @@
using UnityEngine;
using UnityEngine.UI;
public class SettingsWindow : MonoBehaviour
{
[Header("Panels")]
public GameObject generalPanel;
public GameObject audioPanel;
public GameObject graphicsPanel;
public GameObject displayPanel;
[Header("Tab Buttons")]
public Button generalTab;
public Button audioTab;
public Button graphicsTab;
public Button displayTab;
[Header("Action Buttons")]
public Button applyButton;
public Button cancelButton;
public Button defaultsButton;
public Button quitButton;
private GameObject currentPanel;
private void Awake()
{
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ǩҳ<C7A9><D2B3>ť
generalTab.onClick.AddListener(() => SwitchPanel(generalPanel));
audioTab.onClick.AddListener(() => SwitchPanel(audioPanel));
graphicsTab.onClick.AddListener(() => SwitchPanel(graphicsPanel));
displayTab.onClick.AddListener(() => SwitchPanel(displayPanel));
// <20><>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť
applyButton.onClick.AddListener(ApplyAllSettings);
cancelButton.onClick.AddListener(CloseWindow);
defaultsButton.onClick.AddListener(ResetToDefaults);
quitButton.onClick.AddListener(() => { Application.Quit(); });
// Ĭ<>ϴ򿪵<CFB4>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SwitchPanel(generalPanel);
}
private void SwitchPanel(GameObject newPanel)
{
if (currentPanel != null)
currentPanel.SetActive(false);
newPanel.SetActive(true);
currentPanel = newPanel;
UpdateTabButtons();
}
private void UpdateTabButtons()
{
generalTab.interactable = currentPanel != generalPanel;
audioTab.interactable = currentPanel != audioPanel;
graphicsTab.interactable = currentPanel != graphicsPanel;
displayTab.interactable = currentPanel != displayPanel;
}
public void ApplyAllSettings()
{
// Ӧ<><D3A6><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>ã<EFBFBD><C3A3><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>ִ<EFBFBD>У<EFBFBD>
displayPanel.GetComponent<DisplayPanel>().ApplySettings();
// Ӧ<><D3A6>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
graphicsPanel.GetComponent<GraphicsPanel>().ApplySettings();
// Ӧ<><D3A6><EFBFBD><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD><EFBFBD>
audioPanel.GetComponent<AudioPanel>().ApplySettings();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
SettingsManager.Instance.SaveSettings();
CloseWindow();
}
public void CloseWindow()
{
// <20><><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD>
SettingsManager.Instance.LoadSettings();
gameObject.SetActive(false);
}
public void ResetToDefaults()
{
SettingsManager.Instance.ResetToDefaultSettings();
SwitchPanel(currentPanel); // ˢ<>µ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2c613363e91e7c64f86144bb2d1170ed
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class UIBasePanel : MonoBehaviour
{
public virtual void OnShow() { }
public virtual void OnHide() { }
public virtual void Refresh() { }
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2bf3cc6e9e21be7419df9ca4faedb67f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,19 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public abstract class UIBaseWindow : MonoBehaviour
{
public virtual void Show()
{
gameObject.SetActive(true);
OnShow();
}
public virtual void Hide()
{
gameObject.SetActive(true);
OnHide();
}
protected virtual void OnShow() { }
protected virtual void OnHide() { }
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e3f28a4ac0387cf41a8955b532a5fd19
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 865cfb005c2e42a4783a9f7eaa74c930
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -2,26 +2,26 @@ using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Audio;
public class AudioPanel : MonoBehaviour
public class AudioPanel : UIBasePanel, ISettingsPanel
{
[SerializeField] private Slider masterVolumeSlider;
[SerializeField] private AudioMixer audioMixer;
private void OnEnable()
{
masterVolumeSlider.value = SettingsManager.Instance.CurrentSettings.masterVolume;
masterVolumeSlider.value = SettingsManager.Inst.CurrentSettings.masterVolume;
if (audioMixer == null) audioMixer = FindAnyObjectByType<AudioMixer>();
}
public void OnMasterVolumeChanged(float value)
{
SettingsManager.Instance.CurrentSettings.masterVolume = value;
SettingsManager.Inst.CurrentSettings.masterVolume = value;
SetVolume(value);
}
public void ApplySettings()
{
SetVolume(SettingsManager.Instance.CurrentSettings.masterVolume);
SetVolume(SettingsManager.Inst.CurrentSettings.masterVolume);
}
private void SetVolume(float volume)
@@ -29,4 +29,9 @@ public class AudioPanel : MonoBehaviour
if (audioMixer)
audioMixer.SetFloat("MasterVolume", Mathf.Log10(Mathf.Max(volume, 0.0001f)) * 20);
}
public void ResetToDefault()
{
throw new System.NotImplementedException();
}
}

View File

@@ -4,7 +4,7 @@ using System.Collections.Generic;
using TMPro;
using System.Collections;
public class DisplayPanel : MonoBehaviour
public class DisplayPanel : UIBasePanel, ISettingsPanel
{
[Header("UI References")]
[SerializeField] private TMP_Dropdown resolutionDropdown;
@@ -27,7 +27,7 @@ public class DisplayPanel : MonoBehaviour
IEnumerator InitializeDelayed()
{
yield return null;
var settings = SettingsManager.Instance.CurrentSettings;
var settings = SettingsManager.Inst.CurrentSettings;
resolutionDropdown.SetValueWithoutNotify(settings.resolutionIndex);
fullscreenToggle.SetIsOnWithoutNotify(settings.fullscreen);
@@ -45,7 +45,6 @@ public class DisplayPanel : MonoBehaviour
var options = new List<string>();
for (int i = 0; i < resolutions.Length; i++)
{
// 使用refreshRateRatio代替过时的refreshRate
int refreshRate = Mathf.RoundToInt((float)resolutions[i].refreshRateRatio.value);
options.Add($"{resolutions[i].width}x{resolutions[i].height} {refreshRate}Hz");
}
@@ -68,26 +67,26 @@ public class DisplayPanel : MonoBehaviour
public void OnResolutionChanged(int index)
{
SettingsManager.Instance.CurrentSettings.resolutionIndex = index;
SettingsManager.Inst.CurrentSettings.resolutionIndex = index;
ApplySetResolution();
}
public void OnFullscreenChanged(bool value)
{
SettingsManager.Instance.CurrentSettings.fullscreen = value;
SettingsManager.Inst.CurrentSettings.fullscreen = value;
UpdateBorderlessToggleState();
ApplySetResolution();
}
public void OnBorderlessChanged(bool value)
{
SettingsManager.Instance.CurrentSettings.borderless = value;
SettingsManager.Inst.CurrentSettings.borderless = value;
ApplySetResolution();
}
public void OnDisplayChanged(int index)
{
SettingsManager.Instance.CurrentSettings.displayIndex = index;
SettingsManager.Inst.CurrentSettings.displayIndex = index;
ApplySetDisplay();
}
@@ -108,7 +107,7 @@ public class DisplayPanel : MonoBehaviour
void ApplySetResolution()
{
if (resolutions == null) return;
var settings = SettingsManager.Instance.CurrentSettings;
var settings = SettingsManager.Inst.CurrentSettings;
Resolution res = resolutions[resolutions.Length-1];
if (settings.resolutionIndex < resolutions.Length && settings.resolutionIndex>=0)
{
@@ -119,7 +118,6 @@ public class DisplayPanel : MonoBehaviour
FullScreenMode.FullScreenWindow :
(settings.fullscreen ? FullScreenMode.ExclusiveFullScreen : FullScreenMode.Windowed);
// 使用refreshRateRatio代替过时的refreshRate
Screen.SetResolution(
res.width,
res.height,
@@ -129,10 +127,15 @@ public class DisplayPanel : MonoBehaviour
}
void ApplySetDisplay()
{
var settings = SettingsManager.Instance.CurrentSettings;
var settings = SettingsManager.Inst.CurrentSettings;
if (settings.displayIndex > 0 && settings.displayIndex < Display.displays.Length)
{
Display.displays[settings.displayIndex].Activate();
}
}
public void ResetToDefault()
{
throw new System.NotImplementedException();
}
}

View File

@@ -0,0 +1,33 @@
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class GeneralPanel : UIBasePanel,ISettingsPanel
{
[SerializeField] private TMP_InputField serverAddressInput;
public override void OnShow()
{
serverAddressInput.text = SettingsManager.Inst.CurrentSettings.serverAddress;
base.Refresh();
}
public override void Refresh()
{
base.Refresh();
}
public void OnServerAddressChanged(string value)
{
SettingsManager.Inst.CurrentSettings.serverAddress = value;
}
public void ApplySettings()
{
// SettingsManager.Inst.CurrentSettings.serverAddress = value;
}
public void ResetToDefault()
{
}
}

View File

@@ -5,7 +5,7 @@ using UnityEngine.Rendering.Universal;
using TMPro;
using System.Collections;
public class GraphicsPanel : MonoBehaviour
public class GraphicsPanel : UIBasePanel, ISettingsPanel
{
[Header("UI References")]
[SerializeField] private TMP_Dropdown qualityDropdown;
@@ -61,26 +61,23 @@ public class GraphicsPanel : MonoBehaviour
private IEnumerator InitializeDelayed()
{
yield return null; // 等待一帧确保URP初始化
yield return null;
// 获取URP Asset
_urpAsset = GraphicsSettings.currentRenderPipeline as UniversalRenderPipelineAsset;
if (_urpAsset == null)
{
Debug.LogError("无法获取URP Asset请确保项目使用URP");
Debug.LogError("URP Asset null");
yield break;
}
// 获取Bloom效果
if (urpVolumeProfile != null && !urpVolumeProfile.TryGet(out _bloom))
{
Debug.LogWarning("Volume Profile中未找到Bloom效果");
Debug.LogWarning("Volume Profile Bloom null");
}
// 初始化UI
//InitializeQualityDropdown();
var settings = SettingsManager.Instance.CurrentSettings;
var settings = SettingsManager.Inst.CurrentSettings;
qualityDropdown.SetValueWithoutNotify(settings.qualityLevel);
vsyncToggle.SetIsOnWithoutNotify(settings.vsyncEnabled);
shadowDistanceSlider.SetValueWithoutNotify(settings.shadowDistance);
@@ -102,13 +99,13 @@ public class GraphicsPanel : MonoBehaviour
public void OnQualityChanged(int index)
{
SettingsManager.Instance.CurrentSettings.qualityLevel = index;
var settings = SettingsManager.Instance.CurrentSettings;
SettingsManager.Inst.CurrentSettings.qualityLevel = index;
var settings = SettingsManager.Inst.CurrentSettings;
if (index >= 0 && index < qualityPresets.Length)
{
var preset = qualityPresets[index];
// 应用预设的所有设置
// Ӧ<EFBFBD><EFBFBD>Ԥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
vsyncToggle.SetIsOnWithoutNotify(preset.vsyncEnabled);
shadowDistanceSlider.SetValueWithoutNotify(preset.shadowDistance);
antiAliasingDropdown.SetValueWithoutNotify(preset.antiAliasing);
@@ -116,7 +113,7 @@ public class GraphicsPanel : MonoBehaviour
renderScaleSlider.SetValueWithoutNotify(preset.renderScale);
}
// 立即应用设置
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
OnVSyncChanged(settings.vsyncEnabled);
OnShadowDistanceChanged(settings.shadowDistance);
OnAntiAliasingChanged(settings.antiAliasing);
@@ -126,34 +123,34 @@ public class GraphicsPanel : MonoBehaviour
public void OnVSyncChanged(bool value)
{
SettingsManager.Instance.CurrentSettings.vsyncEnabled = value;
SettingsManager.Inst.CurrentSettings.vsyncEnabled = value;
QualitySettings.vSyncCount = value ? 1 : 0;
}
public void OnShadowDistanceChanged(float value)
{
SettingsManager.Instance.CurrentSettings.shadowDistance = value;
SettingsManager.Inst.CurrentSettings.shadowDistance = value;
if (_urpAsset != null)
_urpAsset.shadowDistance = value;
}
public void OnAntiAliasingChanged(int index)
{
SettingsManager.Instance.CurrentSettings.antiAliasing = index;
SettingsManager.Inst.CurrentSettings.antiAliasing = index;
if (_urpAsset != null)
_urpAsset.msaaSampleCount = (int)Mathf.Pow(2, index);
}
public void OnBloomChanged(bool value)
{
SettingsManager.Instance.CurrentSettings.bloomEnabled = value;
SettingsManager.Inst.CurrentSettings.bloomEnabled = value;
if (_bloom != null)
_bloom.active = value;
}
public void OnRenderScaleChanged(float value)
{
SettingsManager.Instance.CurrentSettings.renderScale = value;
SettingsManager.Inst.CurrentSettings.renderScale = value;
if (_urpAsset != null)
_urpAsset.renderScale = value;
}
@@ -162,7 +159,7 @@ public class GraphicsPanel : MonoBehaviour
{
if (_urpAsset == null) return;
var settings = SettingsManager.Instance.CurrentSettings;
var settings = SettingsManager.Inst.CurrentSettings;
if (settings.qualityLevel != 4)
QualitySettings.SetQualityLevel(settings.qualityLevel);
QualitySettings.vSyncCount = settings.vsyncEnabled ? 1 : 0;
@@ -173,4 +170,9 @@ public class GraphicsPanel : MonoBehaviour
if (_bloom != null) _bloom.active = settings.bloomEnabled;
}
public void ResetToDefault()
{
throw new System.NotImplementedException();
}
}

View File

@@ -3,28 +3,16 @@ using System.IO;
using YooAsset;
using System;
public class SettingsManager : MonoBehaviour
public class SettingsManager: Singleton<SettingsManager>
{
public static SettingsManager Instance { get; private set; }
private GameSettings _currentSettings;
private SettingsWindow settingsWindow;
public GameSettings CurrentSettings => _currentSettings;
private string settingsPath;
private void Awake()
public SettingsManager()
{
if (Instance != null && Instance != this)
{
Destroy(gameObject);
return;
}
Instance = this;
DontDestroyOnLoad(gameObject);
settingsPath = Path.Combine(Application.persistentDataPath, "settings.json");
LoadSettings();
Debug.Log("SettingsManager 初始化完成");
}
public void LoadSettings()
@@ -50,27 +38,6 @@ public class SettingsManager : MonoBehaviour
_currentSettings = new GameSettings();
SaveSettings();
}
public void OpenSettingWindow()
{
if (settingsWindow != null)
{
settingsWindow.gameObject.SetActive(true);
}
else
{
YooAssets.LoadAssetAsync<GameObject>("SettingsWindow").Completed += (handle) =>
{
settingsWindow = GameObject.Instantiate((GameObject)handle.AssetObject, GameManager.Inst.MainUICanvas.transform).GetComponent<SettingsWindow>();
};
}
}
public void CloseSettingWindow()
{
if (settingsWindow != null)
{
settingsWindow.gameObject.SetActive(false);
}
}
}
[System.Serializable]
@@ -91,4 +58,9 @@ public class GameSettings
public bool fullscreen = true;
public bool borderless = false;
public int displayIndex = 0;
}
public interface ISettingsPanel
{
void ApplySettings();
void ResetToDefault();
}

View File

@@ -0,0 +1,83 @@
using UnityEngine;
using UnityEngine.UI;
public class SettingsWindow : UIBaseWindow
{
[Header("Panels")]
public GeneralPanel generalPanel;
public AudioPanel audioPanel;
public GraphicsPanel graphicsPanel;
public DisplayPanel displayPanel;
[Header("Tab Buttons")]
public Button generalTab;
public Button audioTab;
public Button graphicsTab;
public Button displayTab;
[Header("Action Buttons")]
public Button applyButton;
public Button cancelButton;
public Button defaultsButton;
public Button quitButton;
private UIBasePanel currentPanel;
bool init = false;
protected override void OnShow()
{
if (!init)
{
generalTab.onClick.AddListener(() => SwitchPanel(generalPanel));
audioTab.onClick.AddListener(() => SwitchPanel(audioPanel));
graphicsTab.onClick.AddListener(() => SwitchPanel(graphicsPanel));
displayTab.onClick.AddListener(() => SwitchPanel(displayPanel));
applyButton.onClick.AddListener(ApplyAllSettings);
cancelButton.onClick.AddListener(() => { UIManager.Inst.HideWindow(gameObject.name); });
defaultsButton.onClick.AddListener(ResetToDefaults);
quitButton.onClick.AddListener(() => { Application.Quit(); });
}
SwitchPanel(generalPanel);
base.OnShow();
}
private void SwitchPanel(UIBasePanel newPanel)
{
if (currentPanel != null)
currentPanel.gameObject.SetActive(false);
newPanel.gameObject.SetActive(true);
currentPanel = newPanel;
UpdateTabButtons();
}
private void UpdateTabButtons()
{
generalTab.interactable = currentPanel != generalPanel;
audioTab.interactable = currentPanel != audioPanel;
graphicsTab.interactable = currentPanel != graphicsPanel;
displayTab.interactable = currentPanel != displayPanel;
}
public void ApplyAllSettings()
{
generalPanel.ApplySettings();
displayPanel.ApplySettings();
graphicsPanel.ApplySettings();
audioPanel.ApplySettings();
SettingsManager.Inst.SaveSettings();
UIManager.Inst.HideWindow(gameObject.name);
}
public void ResetToDefaults()
{
SettingsManager.Inst.ResetToDefaultSettings();
SwitchPanel(currentPanel);
}
}

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using YooAsset;
public class UIManager : SingletonMono<UIManager>
{
Transform uiRoot;
Dictionary<string, UIBaseWindow> openedWindows = new Dictionary<string, UIBaseWindow>();
public void ShowWindow<T>(string windowName,Action<T> onShow = null) where T : UIBaseWindow
{
if (openedWindows.ContainsKey(windowName))
{
var window = openedWindows[windowName] as T;
window.Show();
onShow?.Invoke(window);
}
else
{
YooAssets.LoadAssetAsync<GameObject>(windowName).Completed += handle =>
{
GameObject go = Instantiate((GameObject)handle.AssetObject, GameManager.Inst.MainUICanvas.transform);
var window = go.GetComponent<T>();
window.Show();
onShow?.Invoke(window);
};
}
}
public void HideWindow(string windowName)
{
if (openedWindows.ContainsKey(windowName))
{
openedWindows[windowName].Hide();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 20e218836a1c9e345ae1652efb3f2931
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: