修改框架
This commit is contained in:
@@ -1,14 +1,24 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// UI模块
|
||||
/// </summary>
|
||||
public class ModuleUI : ModuleSingle<ModuleUI> {
|
||||
public static EnumPage page;
|
||||
public static event Action<EnumPage> OnJumpPage;
|
||||
|
||||
public UIDocument document;// 绑定文档
|
||||
|
||||
/// <summary> 根目录文档 </summary>
|
||||
public VisualElement root => document.rootVisualElement;
|
||||
|
||||
protected override void Awake() => NoReplace();
|
||||
|
||||
/// <summary> 跳转页面 </summary>
|
||||
public static void Jump(EnumPage pageType) => OnJumpPage?.Invoke(pageType);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b4d3d9edca07b4c4e9e7128eb34a1511
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 测试页面
|
||||
/// </summary>
|
||||
public class UITestPage : ModuleUIPage {
|
||||
public VisualTreeAsset TemplateAsset;
|
||||
public List<string> list;
|
||||
|
||||
private UIToggle toggle;
|
||||
private UIDropdown<string> dropdown;
|
||||
private UIScrollView scrollView;
|
||||
|
||||
public override VisualElement Element => root;
|
||||
|
||||
public VisualElement Toggle => Q<VisualElement>("Toggle");
|
||||
public VisualElement Dropdown => Q<VisualElement>("Dropdown");
|
||||
public VisualElement ScrollView => Q<VisualElement>("ScrollView");
|
||||
|
||||
private void Awake() {
|
||||
toggle = new UIToggle(Toggle);
|
||||
toggle.ValueChanged += (value) => Debug.Log(value);
|
||||
|
||||
dropdown = new UIDropdown<string>(Dropdown, root, TemplateAsset);
|
||||
dropdown.SetValue(list);
|
||||
dropdown.ValueChanged += (value) => Debug.Log(value);
|
||||
|
||||
scrollView = new UIScrollView(ScrollView, root, UIDirection.FromTopToBottom);
|
||||
}
|
||||
private void Update() {
|
||||
dropdown.Update();
|
||||
scrollView.Update();
|
||||
}
|
||||
private void OnDestroy() {
|
||||
dropdown.Release();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a47690fe988195040a2e528bb2e8bce6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 217b5fdf76c9e1e4abbb9bd77f28883e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user