using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
using MuHua;
///
/// UI模块
///
public class ModuleUI : ModuleUISingle {
/// 当前页面
public static Page Current;
/// 回退页面
public static Page BackPage;
/// 控件列表
public static List controls = new List();
/// 页面跳转事件
public static event Action OnJumpPage;
/// 跳转页面
public static void Settings(Page pageType) {
BackPage = Current;
Current = pageType;
OnJumpPage?.Invoke(Current);
}
/// 回退页面
public static void Back() {
Current = BackPage;
OnJumpPage?.Invoke(Current);
}
/// 添加控件
public static void AddControl(UIControl control) {
controls.Add(control);
}
/// 移除控件
public static void RemoveControl(UIControl control) {
controls.Remove(control);
}
public override VisualElement Element => document.rootVisualElement;
protected override void Awake() => NoReplace();
private void Update() => controls.ForEach(control => control.Update());
private void OnDestroy() => controls.ForEach(control => control.Dispose());
}
///
/// 页面
///
public enum Page {
/// 无
None,
/// 登录
Login,
}