增加UIToggle和UIDropdown

This commit is contained in:
MuHua-123
2025-04-22 15:45:57 +08:00
parent f6d1cd4d87
commit 9a34f2bd18
33 changed files with 755 additions and 32 deletions
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: ee662750a93822c408a0c1d04b7bb488
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+14
View File
@@ -0,0 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using MuHua;
/// <summary>
/// UI模块
/// </summary>
public class ModuleUI : ModuleSingle<ModuleUI> {
protected override void Awake() => NoReplace();
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a3ee54ac782eb1d4a9c8b92a859c3d38
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+8
View File
@@ -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: