12345678910111213141516171819202122232425262728293031323334353637 |
- using System;
- using Godot;
- using TBL.GodotSharp.Ui.AutoAdaption;
- namespace TBL.GodotSharp.Ui
- {
- /// <summary>
- /// Ui 根节点
- /// </summary>
- public class UiRoot<TEnumUiLayer> : Control
- where TEnumUiLayer : Enum
- {
- public override void _EnterTree()
- {
- Name = "UiRoot";
- this.SetFullParent();
- foreach (var uiLayerName in Enum.GetNames(typeof(TEnumUiLayer)))
- {
- var layer =
- uiLayerName == "Debug"
- ? new Control()
- : new AutoAdaptionUiRoot();
- layer.Name = uiLayerName;
- layer.MouseFilter = MouseFilterEnum.Pass;
- AddChild(layer);
- if (layer is AutoAdaptionUiRoot)
- {
- layer.SetCenterParent(true);
- }
- else
- {
- layer.SetFullParent();
- }
- }
- }
- }
- }
|