Initial commit
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 687421b262e8f94438ea3821bca49d6b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0fec0c5043434164c8a5cb28f3886b1d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace MuHua {
|
||||
/// <summary>
|
||||
/// UI项
|
||||
/// </summary>
|
||||
public abstract class ModuleUIItem<Data> : ModuleUIPanel {
|
||||
/// <summary> 选择事件 </summary>
|
||||
public static event Action<Data> OnSelect;
|
||||
/// <summary> 触发事件 </summary>
|
||||
public static void Select(Data data) => OnSelect?.Invoke(data);
|
||||
|
||||
/// <summary> 绑定的数据 </summary>
|
||||
public readonly Data value;
|
||||
/// <summary> UI项 </summary>
|
||||
public ModuleUIItem(Data value, VisualElement element) : base(element) {
|
||||
this.value = value;
|
||||
OnSelect += UIItem_OnSelect;
|
||||
}
|
||||
|
||||
/// <summary> 侦听选择事件 </summary>
|
||||
public virtual void UIItem_OnSelect(Data obj) {
|
||||
if (value.Equals(obj)) { SelectState(); } else { DefaultState(); }
|
||||
}
|
||||
|
||||
/// <summary> 触发选择事件 </summary>
|
||||
public virtual void Select() => OnSelect?.Invoke(value);
|
||||
/// <summary> 默认状态 </summary>
|
||||
public virtual void DefaultState() { }
|
||||
/// <summary> 选中状态 </summary>
|
||||
public virtual void SelectState() { }
|
||||
/// <summary> 释放 </summary>
|
||||
public virtual void Release() => OnSelect -= UIItem_OnSelect;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dfa6a8682a5ec384d98b88b54ace505f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,47 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace MuHua {
|
||||
/// <summary>
|
||||
/// UI项容器
|
||||
/// </summary>
|
||||
public class ModuleUIItems<TItem, TData> : ModuleUIPanel where TItem : ModuleUIItem<TData> {
|
||||
public readonly VisualTreeAsset templateAsset;// 模板资源
|
||||
public readonly Func<TData, VisualElement, TItem> generate;// 生成UI项的函数
|
||||
|
||||
public List<TItem> uiItems = new List<TItem>();// UI项列表
|
||||
|
||||
public TItem this[int index] { get => uiItems[index]; }// 索引器
|
||||
|
||||
/// <summary> UI容器 </summary>
|
||||
public ModuleUIItems(VisualElement element, VisualTreeAsset templateAsset, Func<TData, VisualElement, TItem> generate) : base(element) {
|
||||
this.templateAsset = templateAsset;
|
||||
this.generate = generate;
|
||||
}
|
||||
/// <summary> 释放资源 </summary>
|
||||
public void Release() {
|
||||
element.Clear();
|
||||
uiItems.ForEach(obj => obj.Release());
|
||||
uiItems = new List<TItem>();
|
||||
}
|
||||
/// <summary> 创建UI项 </summary>
|
||||
public void Create(List<TData> datas) {
|
||||
Release();
|
||||
datas.ForEach(Create);
|
||||
}
|
||||
/// <summary> 创建UI项 </summary>
|
||||
public void Create(TData data) {
|
||||
VisualElement element = templateAsset.Instantiate();
|
||||
TItem item = generate(data, element);
|
||||
this.element.Add(item.element);
|
||||
uiItems.Add(item);
|
||||
}
|
||||
/// <summary> 遍历 </summary>
|
||||
public void ForEach(Action<TItem> action) {
|
||||
uiItems.ForEach(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5854bcf80117aa49b327f2c19914ba3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace MuHua {
|
||||
/// <summary>
|
||||
/// 页面模块
|
||||
/// </summary>
|
||||
public abstract class ModuleUIPage : MonoBehaviour {
|
||||
/// <summary> 绑定文档 </summary>
|
||||
public UIDocument document;
|
||||
/// <summary> 根目录文档 </summary>
|
||||
public VisualElement root => document.rootVisualElement;
|
||||
/// <summary> 绑定文档 </summary>
|
||||
public abstract VisualElement Element { get; }
|
||||
/// <summary> 添加UI元素 </summary>
|
||||
public void Add(VisualElement child) => Element.Add(child);
|
||||
/// <summary> 查询UI元素 </summary>
|
||||
public T Q<T>(string name = null, string className = null) where T : VisualElement => Element.Q<T>(name, className);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a20e816476c4c5d4b83e112be2e08697
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace MuHua {
|
||||
/// <summary>
|
||||
/// UI控件
|
||||
/// </summary>
|
||||
public class ModuleUIPanel {
|
||||
/// <summary> 绑定的元素 </summary>
|
||||
public readonly VisualElement element;
|
||||
/// <summary> UI控件 </summary>
|
||||
public ModuleUIPanel(VisualElement element) => this.element = element;
|
||||
/// <summary> 查询UI元素 </summary>
|
||||
public T Q<T>(string name = null, string className = null) where T : VisualElement => element.Q<T>(name, className);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 97e1bf60274de61419b2d9588340cafa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5c114499ba33d59478f35ca583231e02
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MuHua {
|
||||
/// <summary>
|
||||
/// 方向
|
||||
/// </summary>
|
||||
public enum UIDirection {
|
||||
FromLeftToRight = 0,
|
||||
FromRightToLeft = 1,
|
||||
FromTopToBottom = 2,
|
||||
FromBottomToTop = 3,
|
||||
|
||||
HorizontalAndVertical = 4,
|
||||
Horizontal = 5,
|
||||
Vertical = 6,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c2b0340184fec6c45815d13d6a1f7321
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
#if ENABLE_INPUT_SYSTEM && UNITY_INPUT_SYSTEM_PACKAGE
|
||||
using UnityEngine.InputSystem;
|
||||
#endif
|
||||
|
||||
namespace MuHua
|
||||
{
|
||||
/// <summary>
|
||||
/// UI工具
|
||||
/// </summary>
|
||||
public static class UITool
|
||||
{
|
||||
/// <summary> 获取鼠标位置 </summary>
|
||||
public static Vector3 GetMousePosition()
|
||||
{
|
||||
#if ENABLE_INPUT_SYSTEM && UNITY_INPUT_SYSTEM_PACKAGE
|
||||
return Mouse.current.position.ReadValue();
|
||||
#else
|
||||
return Input.mousePosition;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac8f1de11a0d473409df019e3d014d21
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 90a36026f648a6f45add234bc15d5548
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,71 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
public class CircularBar : VisualElement {
|
||||
public new class UxmlFactory : UxmlFactory<CircularBar, UxmlTraits> { }
|
||||
public new class UxmlTraits : VisualElement.UxmlTraits {
|
||||
private readonly UxmlFloatAttributeDescription Fill = new() { name = "fill", defaultValue = 0.1f };
|
||||
|
||||
public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc) {
|
||||
base.Init(ve, bag, cc);
|
||||
var circularBar = ve as CircularBar;
|
||||
circularBar.Fill = Fill.GetValueFromBag(bag, cc);
|
||||
circularBar.UpdateValue();
|
||||
}
|
||||
}
|
||||
|
||||
public readonly Material material;
|
||||
public readonly RenderTexture rt;
|
||||
|
||||
public VisualElement visual;
|
||||
|
||||
public float Fill { get; set; }
|
||||
|
||||
public CircularBar() {
|
||||
visual = new VisualElement();
|
||||
visual.style.flexGrow = 1;
|
||||
hierarchy.Add(visual);
|
||||
|
||||
var shader = Shader.Find("MuHua/UI/CircularBar");
|
||||
if (shader == null) {
|
||||
Debug.LogError("Failed to find Shader Graphs/CircularBar.");
|
||||
return;
|
||||
}
|
||||
material = new Material(shader);
|
||||
|
||||
rt = new RenderTexture(128, 128, 0, RenderTextureFormat.ARGBFloat);
|
||||
|
||||
Background background = Background.FromRenderTexture(rt);
|
||||
visual.style.backgroundImage = new StyleBackground(background);
|
||||
}
|
||||
|
||||
public void UpdateValue(float fill) {
|
||||
Fill = fill;
|
||||
UpdateValue();
|
||||
}
|
||||
public void UpdateValue() {
|
||||
if (material == null) { return; }
|
||||
Texture2D texture = resolvedStyle.backgroundImage.texture;
|
||||
if (texture == null) { return; }
|
||||
|
||||
material.SetFloat("_fill", Fill);
|
||||
|
||||
CommandBuffer command = CommandBufferPool.Get();
|
||||
|
||||
// 设置渲染目标为tempRTHandle
|
||||
CoreUtils.SetRenderTarget(command, rt);
|
||||
// 清除纹理内容
|
||||
CoreUtils.ClearRenderTarget(command, ClearFlag.All, Color.clear);
|
||||
// 渲染
|
||||
command.Blit(texture, rt, material, 0);
|
||||
|
||||
Graphics.ExecuteCommandBuffer(command);
|
||||
CommandBufferPool.Release(command);
|
||||
|
||||
Background background = Background.FromRenderTexture(rt);
|
||||
visual.style.backgroundImage = new StyleBackground(background);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dd9bb527169c05848b8946bc93645079
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,30 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace MuHua {
|
||||
public class UIFloatField : FloatField {
|
||||
public new class UxmlFactory : UxmlFactory<UIFloatField, UxmlTraits> { }
|
||||
public new class UxmlTraits : FloatField.UxmlTraits { }
|
||||
public VisualElement inputElement;
|
||||
public VisualElement textElement;
|
||||
public UIFloatField() {
|
||||
ClearClassList();
|
||||
AddToClassList("input-field");
|
||||
|
||||
labelElement.ClearClassList();
|
||||
labelElement.AddToClassList("unity-text-element");
|
||||
labelElement.AddToClassList("input-field-label");
|
||||
|
||||
inputElement = this.Q<VisualElement>("unity-text-input");
|
||||
inputElement.ClearClassList();
|
||||
inputElement.AddToClassList("input-field-box");
|
||||
|
||||
textElement = inputElement.Q<VisualElement>("");
|
||||
textElement.ClearClassList();
|
||||
textElement.AddToClassList("unity-text-element");
|
||||
textElement.AddToClassList("input-field-text");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7046acdb2e5ef0c458969a4022ee9ab4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace MuHua {
|
||||
public class UILongField : LongField {
|
||||
public new class UxmlFactory : UxmlFactory<UILongField, UxmlTraits> { }
|
||||
public new class UxmlTraits : LongField.UxmlTraits { }
|
||||
public UILongField() {
|
||||
ClearClassList();
|
||||
AddToClassList("input-field");
|
||||
|
||||
labelElement.ClearClassList();
|
||||
labelElement.AddToClassList("unity-text-element");
|
||||
labelElement.AddToClassList("input-field-label");
|
||||
|
||||
VisualElement inputElement = this.Q<VisualElement>("unity-text-input");
|
||||
inputElement.ClearClassList();
|
||||
inputElement.AddToClassList("input-field-box");
|
||||
|
||||
VisualElement textElement = inputElement.Q<VisualElement>("");
|
||||
textElement.ClearClassList();
|
||||
textElement.AddToClassList("unity-text-element");
|
||||
textElement.AddToClassList("input-field-text");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d30b5caf969d9b4ab1464d329cf16ca
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,55 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace MuHua {
|
||||
public class UITextField : TextField {
|
||||
public new class UxmlFactory : UxmlFactory<UITextField, UxmlTraits> { }
|
||||
public new class UxmlTraits : TextField.UxmlTraits {
|
||||
public UxmlStringAttributeDescription DefaultPrompt = new UxmlStringAttributeDescription {
|
||||
name = "default-prompt"
|
||||
};
|
||||
public override void Init(VisualElement ve, IUxmlAttributes bag, CreationContext cc) {
|
||||
base.Init(ve, bag, cc);
|
||||
UITextField textField = (UITextField)ve;
|
||||
textField.DefaultPrompt = DefaultPrompt.GetValueFromBag(bag, cc);
|
||||
textField.SetDefaultPrompt();
|
||||
}
|
||||
}
|
||||
public string DefaultPrompt { get; set; }
|
||||
|
||||
public VisualElement inputElement => this.Q<VisualElement>("unity-text-input");
|
||||
public VisualElement textElement => inputElement.Q<VisualElement>("");
|
||||
|
||||
public UITextField() {
|
||||
ClearClassList();
|
||||
AddToClassList("input-field");
|
||||
|
||||
labelElement.ClearClassList();
|
||||
labelElement.AddToClassList("unity-text-element");
|
||||
labelElement.AddToClassList("input-field-label");
|
||||
|
||||
inputElement.ClearClassList();
|
||||
inputElement.AddToClassList("input-field-box");
|
||||
|
||||
textElement.ClearClassList();
|
||||
textElement.AddToClassList("unity-text-element");
|
||||
textElement.AddToClassList("input-field-text");
|
||||
|
||||
RegisterCallback<FocusInEvent>((evt) => { PrepareInput(); });
|
||||
RegisterCallback<FocusOutEvent>((evt) => { SetDefaultPrompt(); });
|
||||
}
|
||||
public void PrepareInput() {
|
||||
textElement.RemoveFromClassList("input-field-text-d");
|
||||
if (text != DefaultPrompt) { return; }
|
||||
text = "";
|
||||
}
|
||||
public void SetDefaultPrompt() {
|
||||
textElement.RemoveFromClassList("input-field-text-d");
|
||||
if (value != "") { return; }
|
||||
text = DefaultPrompt;
|
||||
textElement.AddToClassList("input-field-text-d");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3bbf7cc5bf423304dbb4eac4f82b2bee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: be53e2c2d10706340aa8ed31656a6473
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,124 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace MuHua {
|
||||
/// <summary>
|
||||
/// 下拉框
|
||||
/// </summary>
|
||||
public class UIDropdown<T> : ModuleUIPanel {
|
||||
/// <summary> 绑定的画布 </summary>
|
||||
internal readonly VisualElement canvas;
|
||||
/// <summary> 下拉框容器 </summary>
|
||||
internal readonly VisualElement DropdownContainer;
|
||||
/// <summary> 下拉框滚动视图 </summary>
|
||||
internal readonly VisualElement DropdownScrollView;
|
||||
/// <summary> 选项模板 </summary>
|
||||
internal readonly VisualTreeAsset TemplateAsset;
|
||||
/// <summary> 值改变时 </summary>
|
||||
public event Action<T> ValueChanged;
|
||||
|
||||
public T value;
|
||||
public List<T> list = new List<T>();
|
||||
|
||||
internal UIScrollView scrollView;
|
||||
internal ModuleUIItems<UIDropdownItem, T> DropdownItems;
|
||||
|
||||
/// <summary> 数据操作 </summary
|
||||
public T this[int index] => list[index];
|
||||
/// <summary> 总数 </summary
|
||||
public int Count => list.Count;
|
||||
|
||||
internal Label Tag => Q<Label>("Tag");
|
||||
internal Label Title => Q<Label>("Title");
|
||||
internal VisualElement Input => Q<VisualElement>("Input");
|
||||
internal VisualElement Icon => Q<VisualElement>("Icon");
|
||||
internal VisualElement Positioner => Q<VisualElement>("Positioner");
|
||||
|
||||
public UIDropdown(VisualElement element, VisualElement canvas, VisualTreeAsset TemplateAsset) : base(element) {
|
||||
this.canvas = canvas;
|
||||
this.TemplateAsset = TemplateAsset;
|
||||
|
||||
DropdownContainer = new VisualElement();
|
||||
DropdownContainer.EnableInClassList("dropdown-container", true);
|
||||
DropdownContainer.EnableInClassList("dropdown-hide", true);
|
||||
canvas.Add(DropdownContainer);
|
||||
|
||||
DropdownScrollView = Q<VisualElement>("DropdownScrollView");
|
||||
DropdownScrollView.EnableInClassList("dropdown-hide", false);
|
||||
DropdownContainer.Add(DropdownScrollView);
|
||||
|
||||
scrollView = new UIScrollView(DropdownScrollView, DropdownContainer, UIDirection.FromTopToBottom);
|
||||
DropdownItems = new ModuleUIItems<UIDropdownItem, T>(scrollView.Container, TemplateAsset,
|
||||
(data, element) => new UIDropdownItem(data, element, this));
|
||||
|
||||
Input.RegisterCallback<ClickEvent>(evt => OpenDropdown());
|
||||
DropdownContainer.RegisterCallback<PointerDownEvent>(evt => CloseDropdown());
|
||||
}
|
||||
public virtual void Release() {
|
||||
canvas.Remove(DropdownContainer);
|
||||
DropdownItems.Release();
|
||||
}
|
||||
public virtual void Update() {
|
||||
scrollView.Update();
|
||||
}
|
||||
|
||||
/// <summary> 打开下拉框 </summary>
|
||||
public void OpenDropdown() {
|
||||
float width = Positioner.resolvedStyle.width;
|
||||
Vector2 position = Positioner.worldBound.position;
|
||||
|
||||
DropdownScrollView.style.width = width;
|
||||
DropdownScrollView.style.left = position.x;
|
||||
DropdownScrollView.style.top = position.y;
|
||||
DropdownContainer.EnableInClassList("dropdown-hide", false);
|
||||
|
||||
DropdownItems.Create(list);
|
||||
}
|
||||
/// <summary> 关闭下拉框 </summary>
|
||||
public void CloseDropdown() {
|
||||
DropdownContainer.EnableInClassList("dropdown-hide", true);
|
||||
}
|
||||
|
||||
/// <summary> 更新值 </summary>
|
||||
public void UpdateValue(T value, bool send = true) {
|
||||
this.value = value;
|
||||
Tag.text = value.ToString();
|
||||
if (send) { ValueChanged?.Invoke(value); }
|
||||
}
|
||||
/// <summary> 设置值 </summary>
|
||||
public void SetValue(List<T> list) {
|
||||
this.list = list;
|
||||
if (list.Count > 0) { UpdateValue(list[0], false); }
|
||||
}
|
||||
|
||||
#region UI项定义
|
||||
/// <summary>
|
||||
/// 设置标题 UI项
|
||||
/// </summary>
|
||||
internal class UIDropdownItem : ModuleUIItem<T> {
|
||||
public readonly UIDropdown<T> parent;
|
||||
|
||||
public Button Button => Q<Button>();
|
||||
public VisualElement Check => Q<VisualElement>("Check");
|
||||
|
||||
public UIDropdownItem(T value, VisualElement element, UIDropdown<T> parent) : base(value, element) {
|
||||
this.parent = parent;
|
||||
Button.text = value.ToString();
|
||||
Button.clicked += Select;
|
||||
Check.EnableInClassList("dropdown-hide", !value.Equals(parent.value));
|
||||
}
|
||||
public override void DefaultState() {
|
||||
Check.EnableInClassList("dropdown-hide", true);
|
||||
}
|
||||
public override void SelectState() {
|
||||
parent.UpdateValue(value);
|
||||
parent.CloseDropdown();
|
||||
Check.EnableInClassList("dropdown-hide", false);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 963896b6158778848b262b161abaa3a8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c687fc5835bae974e9dc3fab6bc13af3
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace MuHua {
|
||||
/// <summary>
|
||||
/// 滚动列表
|
||||
/// </summary>
|
||||
public class UIScrollList<T, Data> : UIScrollView where T : ModuleUIItem<Data> {
|
||||
|
||||
private ModuleUIItems<T, Data> Items;// UI项容器
|
||||
|
||||
public UIScrollList(VisualElement element, VisualElement canvas, VisualTreeAsset templateAsset, Func<Data, VisualElement, T> generate,
|
||||
UIDirection direction = UIDirection.HorizontalAndVertical,
|
||||
UIDirection sh = UIDirection.FromLeftToRight,
|
||||
UIDirection sv = UIDirection.FromTopToBottom) : base(element, canvas, direction, sh, sv) {
|
||||
Items = new ModuleUIItems<T, Data>(Container, templateAsset, generate);
|
||||
}
|
||||
/// <summary> 释放资源 </summary>
|
||||
public void Release() => Items.Release();
|
||||
/// <summary> 创建UI项 </summary>
|
||||
public void Create(List<Data> datas) => Items.Create(datas);
|
||||
/// <summary> 创建UI项 </summary>
|
||||
public void Create(Data data) => Items.Create(data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2fb9b587b7ce5d4295f1bb0da1c8d70
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,144 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace MuHua {
|
||||
/// <summary>
|
||||
/// 滚动视图
|
||||
/// </summary>
|
||||
public class UIScrollView : ModuleUIPanel {
|
||||
/// <summary> 绑定的画布 </summary>
|
||||
public readonly VisualElement canvas;
|
||||
/// <summary> 元素方向 </summary>
|
||||
public readonly UIDirection direction;
|
||||
/// <summary> 水平滑动方向 </summary>
|
||||
public readonly UIDirection sh;
|
||||
/// <summary> 垂直滑动方向 </summary>
|
||||
public readonly UIDirection sv;
|
||||
/// <summary> 值改变时 </summary>
|
||||
public event Action<Vector2> ValueChanged;
|
||||
|
||||
public Vector2 value;
|
||||
public bool isDrag;
|
||||
public Vector3 originalPosition;
|
||||
public Vector3 pointerPosition;
|
||||
|
||||
public readonly UIScroller horizontal;
|
||||
public readonly UIScroller vertical;
|
||||
|
||||
public VisualElement Viewport => Q<VisualElement>("Viewport");
|
||||
public VisualElement Container => Q<VisualElement>("Container");
|
||||
public VisualElement ScrollerHorizontal => Q<VisualElement>("ScrollerHorizontal");
|
||||
public VisualElement ScrollerVertical => Q<VisualElement>("ScrollerVertical");
|
||||
|
||||
public UIScrollView(VisualElement element, VisualElement canvas,
|
||||
UIDirection direction = UIDirection.HorizontalAndVertical,
|
||||
UIDirection sh = UIDirection.FromLeftToRight,
|
||||
UIDirection sv = UIDirection.FromTopToBottom) : base(element) {
|
||||
this.canvas = canvas;
|
||||
this.direction = direction;
|
||||
this.sh = sh;
|
||||
this.sv = sv;
|
||||
|
||||
element.generateVisualContent += ElementGenerateVisualContent;
|
||||
|
||||
if (sh == UIDirection.FromLeftToRight) {
|
||||
horizontal = new UIScroller(ScrollerHorizontal, canvas, sh);
|
||||
Viewport.style.flexDirection = FlexDirection.Row;
|
||||
}
|
||||
if (sh == UIDirection.FromRightToLeft) {
|
||||
horizontal = new UIScroller(ScrollerHorizontal, canvas, sh);
|
||||
Viewport.style.flexDirection = FlexDirection.RowReverse;
|
||||
}
|
||||
|
||||
if (sv == UIDirection.FromTopToBottom) {
|
||||
vertical = new UIScroller(ScrollerVertical, canvas, sv);
|
||||
Viewport.style.flexDirection = FlexDirection.Column;
|
||||
}
|
||||
if (sv == UIDirection.FromBottomToTop) {
|
||||
vertical = new UIScroller(ScrollerVertical, canvas, sv);
|
||||
Viewport.style.flexDirection = FlexDirection.ColumnReverse;
|
||||
}
|
||||
|
||||
// 设置事件
|
||||
horizontal.ValueChanged += (x) => { UpdateValue(new Vector2(x, value.y)); };
|
||||
vertical.ValueChanged += (y) => { UpdateValue(new Vector2(value.x, y)); };
|
||||
|
||||
Viewport.RegisterCallback<WheelEvent>(ViewportWheel);
|
||||
Viewport.RegisterCallback<PointerDownEvent>(DraggerDown);
|
||||
Viewport.RegisterCallback<MouseCaptureEvent>((evt) => isDrag = false);
|
||||
// 释放
|
||||
canvas.RegisterCallback<PointerUpEvent>((evt) => isDrag = false);
|
||||
canvas.RegisterCallback<PointerLeaveEvent>((evt) => isDrag = false);
|
||||
}
|
||||
/// <summary> 视图原始更新 </summary>
|
||||
private void ElementGenerateVisualContent(MeshGenerationContext context) {
|
||||
float width = Mathf.Clamp01(Viewport.resolvedStyle.width / Container.resolvedStyle.width);
|
||||
float height = Mathf.Clamp01(Viewport.resolvedStyle.height / Container.resolvedStyle.height);
|
||||
|
||||
horizontal.Dragger.style.width = Length.Percent(width * 100);
|
||||
vertical.Dragger.style.height = Length.Percent(height * 100);
|
||||
}
|
||||
/// <summary> 视图滚轮滑动 </summary>
|
||||
private void ViewportWheel(WheelEvent evt) {
|
||||
float wheel = Mathf.Clamp(evt.delta.y, -1, 1);
|
||||
Vector2 offset = new Vector2(0, wheel);
|
||||
if (direction == UIDirection.Horizontal) { offset = new Vector2(wheel, 0); }
|
||||
UpdateValue(new Vector2(value.x, value.y) - offset);
|
||||
}
|
||||
private void DraggerDown(PointerDownEvent evt) {
|
||||
isDrag = true;
|
||||
originalPosition = Container.transform.position;
|
||||
Vector3 mousePosition = UITool.GetMousePosition();
|
||||
pointerPosition = new Vector3(mousePosition.x, Screen.height - mousePosition.y);
|
||||
}
|
||||
|
||||
/// <summary> 更新状态 </summary>
|
||||
public virtual void Update() {
|
||||
horizontal.Update();
|
||||
vertical.Update();
|
||||
|
||||
Vector2 original = value;
|
||||
float maxX = Viewport.resolvedStyle.width < Container.resolvedStyle.width ? 1 : 0;
|
||||
float maxY = Viewport.resolvedStyle.height < Container.resolvedStyle.height ? 1 : 0;
|
||||
if (value.x < 0) { value.x = Mathf.Lerp(value.x, 0, Time.deltaTime * 10); }
|
||||
if (value.x > maxX) { value.x = Mathf.Lerp(value.x, maxX, Time.deltaTime * 10); }
|
||||
if (value.y < 0) { value.y = Mathf.Lerp(value.y, 0, Time.deltaTime * 10); }
|
||||
if (value.y > maxY) { value.y = Mathf.Lerp(value.y, maxY, Time.deltaTime * 10); }
|
||||
|
||||
if (original != value) { UpdateValue(value); }
|
||||
|
||||
if (!isDrag) { return; }
|
||||
Vector3 mousePosition = UITool.GetMousePosition();
|
||||
Vector3 differ = new Vector3(mousePosition.x, Screen.height - mousePosition.y) - pointerPosition;
|
||||
Vector3 offset = differ + originalPosition;
|
||||
float maxWidth = Viewport.resolvedStyle.width - Container.resolvedStyle.width;
|
||||
float maxHeight = Viewport.resolvedStyle.height - Container.resolvedStyle.height;
|
||||
|
||||
float x = offset.x / maxWidth;
|
||||
float y = offset.y / maxHeight;
|
||||
x *= sh == UIDirection.FromLeftToRight ? 1 : -1;
|
||||
y *= sv == UIDirection.FromTopToBottom ? 1 : -1;
|
||||
UpdateValue(new Vector2(x, y));
|
||||
}
|
||||
/// <summary> 更新值(0-1) </summary>
|
||||
public void UpdateValue(Vector2 value, bool send = true) {
|
||||
if (direction == UIDirection.Horizontal) { value.y = 0; }
|
||||
if (direction == UIDirection.Vertical) { value.x = 0; }
|
||||
this.value = value;
|
||||
if (send) { ValueChanged?.Invoke(value); }
|
||||
float maxWidth = Viewport.resolvedStyle.width - Container.resolvedStyle.width;
|
||||
float maxHeight = Viewport.resolvedStyle.height - Container.resolvedStyle.height;
|
||||
float xPos = maxWidth * value.x;
|
||||
float yPos = maxHeight * value.y;
|
||||
xPos *= sh == UIDirection.FromLeftToRight ? 1 : -1;
|
||||
yPos *= sv == UIDirection.FromTopToBottom ? 1 : -1;
|
||||
Container.transform.position = new Vector3(xPos, yPos);
|
||||
|
||||
if (horizontal.value != value.x) { horizontal.UpdateValue(value.x, false); }
|
||||
if (vertical.value != value.y) { vertical.UpdateValue(value.y, false); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9fa4135858d72ac4e8a90212625ec7db
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,117 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace MuHua {
|
||||
/// <summary>
|
||||
/// 滚动视图 - 垂直
|
||||
/// </summary>
|
||||
public class UIScrollViewV : ModuleUIPanel {
|
||||
/// <summary> 绑定的画布 </summary>
|
||||
public readonly VisualElement canvas;
|
||||
/// <summary> 元素方向 </summary>
|
||||
public readonly UIDirection direction;
|
||||
/// <summary> 垂直滑块 </summary>
|
||||
public readonly UIScroller vertical;
|
||||
/// <summary> 值改变时 </summary>
|
||||
public event Action<float> ValueChanged;
|
||||
|
||||
/// <summary>
|
||||
/// 方向
|
||||
/// </summary>
|
||||
public enum UIDirection {
|
||||
FromTopToBottom = 0,
|
||||
FromBottomToTop = 1,
|
||||
}
|
||||
|
||||
public float value;
|
||||
public bool isDrag;
|
||||
public Vector3 originalPosition;
|
||||
public Vector3 pointerPosition;
|
||||
|
||||
public VisualElement Viewport => Q<VisualElement>("Viewport");
|
||||
public VisualElement Container => Q<VisualElement>("Container");
|
||||
public VisualElement ScrollerVertical => Q<VisualElement>("ScrollerVertical");
|
||||
|
||||
public UIScrollViewV(VisualElement element, VisualElement canvas, UIDirection direction) : base(element) {
|
||||
this.canvas = canvas;
|
||||
this.direction = direction;
|
||||
|
||||
if (direction == UIDirection.FromTopToBottom) {
|
||||
// vertical = new UIScroller(ScrollerVertical, canvas, direction);
|
||||
Viewport.style.flexDirection = FlexDirection.Column;
|
||||
}
|
||||
if (direction == UIDirection.FromBottomToTop) {
|
||||
// vertical = new UIScroller(ScrollerVertical, canvas, direction);
|
||||
Viewport.style.flexDirection = FlexDirection.ColumnReverse;
|
||||
}
|
||||
|
||||
// 设置事件
|
||||
vertical.ValueChanged += (y) => { UpdateValue(y); };
|
||||
|
||||
Viewport.RegisterCallback<WheelEvent>(ViewportWheel);
|
||||
Viewport.RegisterCallback<PointerDownEvent>(DraggerDown);
|
||||
Viewport.RegisterCallback<MouseCaptureEvent>((evt) => isDrag = false);
|
||||
// 释放
|
||||
canvas.RegisterCallback<PointerUpEvent>((evt) => isDrag = false);
|
||||
canvas.RegisterCallback<PointerLeaveEvent>((evt) => isDrag = false);
|
||||
// 视图原始更新
|
||||
element.generateVisualContent += ElementGenerateVisualContent;
|
||||
}
|
||||
/// <summary> 原始更新 </summary>
|
||||
private void ElementGenerateVisualContent(MeshGenerationContext context) {
|
||||
float height = Mathf.Clamp01(Viewport.resolvedStyle.height / Container.resolvedStyle.height);
|
||||
vertical.Dragger.style.height = Length.Percent(height * 100);
|
||||
}
|
||||
/// <summary> 滚轮滑动 </summary>
|
||||
private void ViewportWheel(WheelEvent evt) {
|
||||
float wheel = Mathf.Clamp(evt.delta.y, -1, 1);
|
||||
UpdateValue(value - wheel);
|
||||
}
|
||||
/// <summary> 拖拽按下 </summary>
|
||||
private void DraggerDown(PointerDownEvent evt) {
|
||||
isDrag = true;
|
||||
originalPosition = Container.transform.position;
|
||||
Vector3 mousePosition = UITool.GetMousePosition();
|
||||
pointerPosition = new Vector3(mousePosition.x, Screen.height - mousePosition.y);
|
||||
}
|
||||
/// <summary> 拖拽滑动 </summary>
|
||||
private void Dragger() {
|
||||
Vector3 mousePosition = UITool.GetMousePosition();
|
||||
Vector3 differ = new Vector3(mousePosition.x, Screen.height - mousePosition.y) - pointerPosition;
|
||||
Vector3 offset = differ + originalPosition;
|
||||
|
||||
float maxHeight = Viewport.resolvedStyle.height - Container.resolvedStyle.height;
|
||||
float y = offset.y / maxHeight;
|
||||
y *= direction == UIDirection.FromTopToBottom ? 1 : -1;
|
||||
UpdateValue(y);
|
||||
}
|
||||
/// <summary> 滑动弹性 </summary>
|
||||
private void SlidingElasticity() {
|
||||
float original = value;
|
||||
float max = Viewport.resolvedStyle.height < Container.resolvedStyle.height ? 1 : 0;
|
||||
if (value < 0) { value = Mathf.Lerp(value, 0, Time.deltaTime * 10); }
|
||||
if (value > max) { value = Mathf.Lerp(value, max, Time.deltaTime * 10); }
|
||||
if (original != value) { UpdateValue(value); }
|
||||
}
|
||||
|
||||
/// <summary> 更新状态 </summary>
|
||||
public virtual void Update() {
|
||||
vertical.Update();
|
||||
SlidingElasticity();
|
||||
if (isDrag) { Dragger(); }
|
||||
}
|
||||
/// <summary> 更新值(0-1) </summary>
|
||||
public virtual void UpdateValue(float value, bool send = true) {
|
||||
this.value = value;
|
||||
if (send) { ValueChanged?.Invoke(value); }
|
||||
float maxHeight = Viewport.resolvedStyle.height - Container.resolvedStyle.height;
|
||||
float position = maxHeight * value;
|
||||
position *= direction == UIDirection.FromTopToBottom ? 1 : -1;
|
||||
Container.transform.position = new Vector3(0, position);
|
||||
if (vertical.value != value) { vertical.UpdateValue(value, false); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ecfd61355ce764642865903953329f1e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a21c9c3bc30a9cf4091edd963a99f7af
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,202 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace MuHua {
|
||||
/// <summary>
|
||||
/// 滚动条
|
||||
/// </summary>
|
||||
public class UIScroller : ModuleUIPanel {
|
||||
/// <summary> 绑定的画布 </summary>
|
||||
public readonly VisualElement canvas;
|
||||
/// <summary> 元素方向 </summary>
|
||||
public readonly UIDirection direction;
|
||||
/// <summary> 值改变时 </summary>
|
||||
public event Action<float> ValueChanged;
|
||||
|
||||
public float value;
|
||||
public bool isDragger;
|
||||
public float originalPosition;
|
||||
public float pointerPosition;
|
||||
|
||||
public readonly UIScrollerFunc scrollerFunc;
|
||||
|
||||
public VisualElement Dragger => Q<VisualElement>("Dragger");
|
||||
|
||||
public UIScroller(VisualElement element, VisualElement canvas, UIDirection direction = UIDirection.FromLeftToRight) : base(element) {
|
||||
this.canvas = canvas;
|
||||
this.direction = direction;
|
||||
|
||||
if (direction == UIDirection.FromLeftToRight) { scrollerFunc = new FromLeftToRight(this); }
|
||||
if (direction == UIDirection.FromRightToLeft) { scrollerFunc = new FromRightToLeft(this); }
|
||||
if (direction == UIDirection.FromTopToBottom) { scrollerFunc = new FromTopToBottom(this); }
|
||||
if (direction == UIDirection.FromBottomToTop) { scrollerFunc = new FromBottomToTop(this); }
|
||||
|
||||
//设置事件
|
||||
Dragger.RegisterCallback<PointerDownEvent>(DraggerDown);
|
||||
element.RegisterCallback<PointerDownEvent>(ElementDown);
|
||||
|
||||
canvas.RegisterCallback<PointerUpEvent>((evt) => isDragger = false);
|
||||
canvas.RegisterCallback<PointerLeaveEvent>((evt) => isDragger = false);
|
||||
}
|
||||
/// <summary> 拖拽元素 </summary>
|
||||
private void DraggerDown(PointerDownEvent evt) => scrollerFunc.DraggerDown(evt);
|
||||
/// <summary> 按下元素 </summary>
|
||||
private void ElementDown(PointerDownEvent evt) => scrollerFunc.ElementDown(evt);
|
||||
/// <summary> 更新状态 </summary>
|
||||
public void Update() => scrollerFunc.Update();
|
||||
/// <summary> 更新值(0-1) </summary>
|
||||
public void UpdateValue(float value, bool send = true) => scrollerFunc.UpdateValue(value, send);
|
||||
|
||||
public abstract class UIScrollerFunc {
|
||||
public readonly UIScroller scroller;
|
||||
public UIScrollerFunc(UIScroller scroller) => this.scroller = scroller;
|
||||
/// <summary> 拖拽元素 </summary>
|
||||
public abstract void DraggerDown(PointerDownEvent evt);
|
||||
/// <summary> 按下元素 </summary>
|
||||
public abstract void ElementDown(PointerDownEvent evt);
|
||||
/// <summary> 更新状态 </summary>
|
||||
public abstract void Update();
|
||||
/// <summary> 更新值(0-1) </summary>
|
||||
public abstract void UpdateValue(float value, bool send = true);
|
||||
}
|
||||
/// <summary>
|
||||
/// 滑块从左到右
|
||||
/// </summary>
|
||||
public class FromLeftToRight : UIScrollerFunc {
|
||||
public FromLeftToRight(UIScroller scroller) : base(scroller) {
|
||||
scroller.element.style.flexDirection = FlexDirection.Row;
|
||||
}
|
||||
public override void DraggerDown(PointerDownEvent evt) {
|
||||
scroller.isDragger = true;
|
||||
scroller.originalPosition = scroller.Dragger.transform.position.x;
|
||||
scroller.pointerPosition = UITool.GetMousePosition().x;
|
||||
}
|
||||
public override void ElementDown(PointerDownEvent evt) {
|
||||
float offset = evt.localPosition.x - scroller.Dragger.resolvedStyle.width * 0.5f;
|
||||
float max = scroller.element.resolvedStyle.width - scroller.Dragger.resolvedStyle.width;
|
||||
float value = Mathf.InverseLerp(0, max, offset);
|
||||
UpdateValue(value);
|
||||
}
|
||||
public override void Update() {
|
||||
if (!scroller.isDragger) { return; }
|
||||
float differ = UITool.GetMousePosition().x - scroller.pointerPosition;
|
||||
float offset = differ + scroller.originalPosition;
|
||||
float max = scroller.element.resolvedStyle.width - scroller.Dragger.resolvedStyle.width;
|
||||
float value = Mathf.InverseLerp(0, max, offset);
|
||||
UpdateValue(value);
|
||||
}
|
||||
public override void UpdateValue(float value, bool send = true) {
|
||||
scroller.value = value;
|
||||
if (send) { scroller.ValueChanged?.Invoke(value); }
|
||||
float max = scroller.element.resolvedStyle.width - scroller.Dragger.resolvedStyle.width;
|
||||
float x = Mathf.Lerp(0, max, value);
|
||||
scroller.Dragger.transform.position = new Vector3(x, 0);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 滑块从右到左
|
||||
/// </summary>
|
||||
public class FromRightToLeft : UIScrollerFunc {
|
||||
public FromRightToLeft(UIScroller scroller) : base(scroller) {
|
||||
scroller.element.style.flexDirection = FlexDirection.RowReverse;
|
||||
}
|
||||
public override void DraggerDown(PointerDownEvent evt) {
|
||||
scroller.isDragger = true;
|
||||
scroller.originalPosition = scroller.Dragger.transform.position.x;
|
||||
scroller.pointerPosition = UITool.GetMousePosition().x;
|
||||
}
|
||||
public override void ElementDown(PointerDownEvent evt) {
|
||||
float offset = evt.localPosition.x - scroller.Dragger.resolvedStyle.width * 0.5f;
|
||||
float max = scroller.element.resolvedStyle.width - scroller.Dragger.resolvedStyle.width;
|
||||
float value = Mathf.InverseLerp(max, 0, offset);
|
||||
UpdateValue(value);
|
||||
}
|
||||
public override void Update() {
|
||||
if (!scroller.isDragger) { return; }
|
||||
float differ = UITool.GetMousePosition().x - scroller.pointerPosition;
|
||||
float offset = differ + scroller.originalPosition;
|
||||
float max = scroller.element.resolvedStyle.width - scroller.Dragger.resolvedStyle.width;
|
||||
float value = Mathf.InverseLerp(max, 0, offset);
|
||||
UpdateValue(value);
|
||||
}
|
||||
public override void UpdateValue(float value, bool send = true) {
|
||||
scroller.value = value;
|
||||
if (send) { scroller.ValueChanged?.Invoke(value); }
|
||||
float max = scroller.element.resolvedStyle.width - scroller.Dragger.resolvedStyle.width;
|
||||
float x = Mathf.Lerp(max, 0, value);
|
||||
scroller.Dragger.transform.position = new Vector3(x, 0);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 滑块从上到下
|
||||
/// </summary>
|
||||
public class FromTopToBottom : UIScrollerFunc {
|
||||
public FromTopToBottom(UIScroller scroller) : base(scroller) {
|
||||
scroller.element.style.flexDirection = FlexDirection.Column;
|
||||
}
|
||||
public override void DraggerDown(PointerDownEvent evt) {
|
||||
scroller.isDragger = true;
|
||||
scroller.originalPosition = scroller.Dragger.transform.position.y;
|
||||
scroller.pointerPosition = Screen.height - UITool.GetMousePosition().y;
|
||||
}
|
||||
public override void ElementDown(PointerDownEvent evt) {
|
||||
float offset = evt.localPosition.y - scroller.Dragger.resolvedStyle.height * 0.5f;
|
||||
float max = scroller.element.resolvedStyle.height - scroller.Dragger.resolvedStyle.height;
|
||||
float value = Mathf.InverseLerp(0, max, offset);
|
||||
UpdateValue(value);
|
||||
}
|
||||
public override void Update() {
|
||||
if (!scroller.isDragger) { return; }
|
||||
float differ = Screen.height - UITool.GetMousePosition().y - scroller.pointerPosition;
|
||||
float offset = differ + scroller.originalPosition;
|
||||
float max = scroller.element.resolvedStyle.height - scroller.Dragger.resolvedStyle.height;
|
||||
float value = Mathf.InverseLerp(0, max, offset);
|
||||
UpdateValue(value);
|
||||
}
|
||||
public override void UpdateValue(float value, bool send = true) {
|
||||
scroller.value = value;
|
||||
if (send) { scroller.ValueChanged?.Invoke(value); }
|
||||
float max = scroller.element.resolvedStyle.height - scroller.Dragger.resolvedStyle.height;
|
||||
float y = Mathf.Lerp(0, max, value);
|
||||
scroller.Dragger.transform.position = new Vector3(0, y);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 滑块从下到上
|
||||
/// </summary>
|
||||
public class FromBottomToTop : UIScrollerFunc {
|
||||
public FromBottomToTop(UIScroller scroller) : base(scroller) {
|
||||
scroller.element.style.flexDirection = FlexDirection.ColumnReverse;
|
||||
}
|
||||
public override void DraggerDown(PointerDownEvent evt) {
|
||||
scroller.isDragger = true;
|
||||
scroller.originalPosition = scroller.Dragger.transform.position.y;
|
||||
scroller.pointerPosition = Screen.height - UITool.GetMousePosition().y;
|
||||
}
|
||||
public override void ElementDown(PointerDownEvent evt) {
|
||||
float offset = evt.localPosition.y - scroller.Dragger.resolvedStyle.height * 0.5f;
|
||||
float max = scroller.element.resolvedStyle.height - scroller.Dragger.resolvedStyle.height;
|
||||
float value = Mathf.InverseLerp(max, 0, offset);
|
||||
UpdateValue(value);
|
||||
}
|
||||
public override void Update() {
|
||||
if (!scroller.isDragger) { return; }
|
||||
float differ = Screen.height - UITool.GetMousePosition().y - scroller.pointerPosition;
|
||||
float offset = differ + scroller.originalPosition;
|
||||
float max = scroller.element.resolvedStyle.height - scroller.Dragger.resolvedStyle.height;
|
||||
float value = Mathf.InverseLerp(max, 0, offset);
|
||||
UpdateValue(value);
|
||||
}
|
||||
public override void UpdateValue(float value, bool send = true) {
|
||||
scroller.value = value;
|
||||
if (send) { scroller.ValueChanged?.Invoke(value); }
|
||||
float max = scroller.Dragger.resolvedStyle.height - scroller.element.resolvedStyle.height;
|
||||
float y = Mathf.Lerp(0, max, value);
|
||||
scroller.Dragger.transform.position = new Vector3(0, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b0bf333809175ae4ebc4469feab46cc7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace MuHua {
|
||||
/// <summary>
|
||||
/// 滚动条 - 垂直
|
||||
/// </summary>
|
||||
public class UIScrollerV : MonoBehaviour {
|
||||
// Start is called before the first frame update
|
||||
void Start() {
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update() {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e1f4e6e2ba12e0b46b1ec2698a680e87
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,179 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace MuHua {
|
||||
/// <summary>
|
||||
/// 滑块
|
||||
/// </summary>
|
||||
public class UISlider : ModuleUIPanel {
|
||||
/// <summary> 绑定的画布 </summary>
|
||||
public readonly VisualElement canvas;
|
||||
/// <summary> 元素方向 </summary>
|
||||
public readonly UIDirection direction;
|
||||
/// <summary> 值改变时 </summary>
|
||||
public event Action<float> ValueChanged;
|
||||
|
||||
public float value;
|
||||
public bool isDragger;
|
||||
public float originalPosition;
|
||||
public float pointerPosition;
|
||||
|
||||
public readonly UISliderFunc sliderFunc;
|
||||
|
||||
public VisualElement Container => Q<VisualElement>("Container");
|
||||
public VisualElement Title => Q<VisualElement>("Title");
|
||||
public VisualElement Tracker => Q<VisualElement>("Tracker");
|
||||
public VisualElement Dragger => Q<VisualElement>("Dragger");
|
||||
|
||||
public UISlider(VisualElement element, VisualElement canvas, UIDirection direction = UIDirection.FromLeftToRight) : base(element) {
|
||||
this.canvas = canvas;
|
||||
this.direction = direction;
|
||||
|
||||
if (direction == UIDirection.FromLeftToRight) { sliderFunc = new FromLeftToRight(this); }
|
||||
if (direction == UIDirection.FromRightToLeft) { sliderFunc = new FromRightToLeft(this); }
|
||||
if (direction == UIDirection.FromTopToBottom) { sliderFunc = new FromTopToBottom(this); }
|
||||
if (direction == UIDirection.FromBottomToTop) { sliderFunc = new FromBottomToTop(this); }
|
||||
|
||||
//设置事件
|
||||
Dragger.RegisterCallback<PointerDownEvent>(DraggerDown);
|
||||
Container.RegisterCallback<PointerDownEvent>(ElementDown);
|
||||
|
||||
canvas.RegisterCallback<PointerUpEvent>((evt) => isDragger = false);
|
||||
canvas.RegisterCallback<PointerLeaveEvent>((evt) => isDragger = false);
|
||||
}
|
||||
|
||||
private void DraggerDown(PointerDownEvent evt) => sliderFunc.DraggerDown(evt);
|
||||
private void ElementDown(PointerDownEvent evt) => sliderFunc.ElementDown(evt);
|
||||
/// <summary> 更新状态 </summary>
|
||||
public void Update() => sliderFunc.Update();
|
||||
/// <summary> 更新值(0-1) </summary>
|
||||
public void UpdateValue(float value, bool send = true) => sliderFunc.UpdateValue(value, send);
|
||||
|
||||
public abstract class UISliderFunc {
|
||||
public readonly UISlider slider;
|
||||
public UISliderFunc(UISlider slider) => this.slider = slider;
|
||||
|
||||
public abstract void DraggerDown(PointerDownEvent evt);
|
||||
public abstract void ElementDown(PointerDownEvent evt);
|
||||
/// <summary> 更新状态 </summary>
|
||||
public abstract void Update();
|
||||
/// <summary> 更新值(0-1) </summary>
|
||||
public abstract void UpdateValue(float value, bool send = true);
|
||||
}
|
||||
|
||||
public class FromLeftToRight : UISliderFunc {
|
||||
public FromLeftToRight(UISlider slider) : base(slider) { }
|
||||
public override void DraggerDown(PointerDownEvent evt) {
|
||||
slider.isDragger = true;
|
||||
slider.originalPosition = slider.Tracker.resolvedStyle.width;
|
||||
slider.pointerPosition = UITool.GetMousePosition().x;
|
||||
}
|
||||
public override void ElementDown(PointerDownEvent evt) {
|
||||
float offset = evt.localPosition.x;
|
||||
float max = slider.Container.resolvedStyle.width;
|
||||
float value = Mathf.InverseLerp(0, max, offset);
|
||||
UpdateValue(value);
|
||||
}
|
||||
public override void Update() {
|
||||
if (!slider.isDragger) { return; }
|
||||
float differ = UITool.GetMousePosition().x - slider.pointerPosition;
|
||||
float offset = differ + slider.originalPosition;
|
||||
float max = slider.Container.resolvedStyle.width;
|
||||
float value = Mathf.InverseLerp(0, max, offset);
|
||||
UpdateValue(value);
|
||||
}
|
||||
public override void UpdateValue(float value, bool send = true) {
|
||||
slider.value = value;
|
||||
if (send) { slider.ValueChanged?.Invoke(value); }
|
||||
slider.Tracker.style.width = Length.Percent(value * 100);
|
||||
}
|
||||
}
|
||||
|
||||
public class FromRightToLeft : UISliderFunc {
|
||||
public FromRightToLeft(UISlider slider) : base(slider) { }
|
||||
public override void DraggerDown(PointerDownEvent evt) {
|
||||
slider.isDragger = true;
|
||||
slider.originalPosition = slider.Container.resolvedStyle.width - slider.Tracker.resolvedStyle.width;
|
||||
slider.pointerPosition = UITool.GetMousePosition().x;
|
||||
}
|
||||
public override void ElementDown(PointerDownEvent evt) {
|
||||
float offset = evt.localPosition.x;
|
||||
float max = slider.Container.resolvedStyle.width;
|
||||
float value = Mathf.InverseLerp(max, 0, offset);
|
||||
UpdateValue(value);
|
||||
}
|
||||
public override void Update() {
|
||||
if (!slider.isDragger) { return; }
|
||||
float differ = UITool.GetMousePosition().x - slider.pointerPosition;
|
||||
float offset = differ + slider.originalPosition;
|
||||
float max = slider.Container.resolvedStyle.width;
|
||||
float value = Mathf.InverseLerp(max, 0, offset);
|
||||
UpdateValue(value);
|
||||
}
|
||||
public override void UpdateValue(float value, bool send = true) {
|
||||
slider.value = value;
|
||||
if (send) { slider.ValueChanged?.Invoke(value); }
|
||||
slider.Tracker.style.width = Length.Percent(value * 100);
|
||||
}
|
||||
}
|
||||
|
||||
public class FromTopToBottom : UISliderFunc {
|
||||
public FromTopToBottom(UISlider slider) : base(slider) { }
|
||||
public override void DraggerDown(PointerDownEvent evt) {
|
||||
slider.isDragger = true;
|
||||
slider.originalPosition = slider.Tracker.resolvedStyle.height;
|
||||
slider.pointerPosition = Screen.height - UITool.GetMousePosition().y;
|
||||
}
|
||||
public override void ElementDown(PointerDownEvent evt) {
|
||||
float offset = evt.localPosition.y;
|
||||
float max = slider.Container.resolvedStyle.height;
|
||||
float value = Mathf.InverseLerp(0, max, offset);
|
||||
UpdateValue(value);
|
||||
}
|
||||
public override void Update() {
|
||||
if (!slider.isDragger) { return; }
|
||||
float differ = Screen.height - UITool.GetMousePosition().y - slider.pointerPosition;
|
||||
float offset = differ + slider.originalPosition;
|
||||
float max = slider.Container.resolvedStyle.height;
|
||||
float value = Mathf.InverseLerp(0, max, offset);
|
||||
UpdateValue(value);
|
||||
}
|
||||
public override void UpdateValue(float value, bool send = true) {
|
||||
slider.value = value;
|
||||
if (send) { slider.ValueChanged?.Invoke(value); }
|
||||
slider.Tracker.style.height = Length.Percent(value * 100);
|
||||
}
|
||||
}
|
||||
|
||||
public class FromBottomToTop : UISliderFunc {
|
||||
public FromBottomToTop(UISlider slider) : base(slider) { }
|
||||
public override void DraggerDown(PointerDownEvent evt) {
|
||||
slider.isDragger = true;
|
||||
slider.originalPosition = slider.Container.resolvedStyle.height - slider.Tracker.resolvedStyle.height;
|
||||
slider.pointerPosition = Screen.height - UITool.GetMousePosition().y;
|
||||
}
|
||||
public override void ElementDown(PointerDownEvent evt) {
|
||||
float offset = evt.localPosition.y;
|
||||
float max = slider.Container.resolvedStyle.height;
|
||||
float value = Mathf.InverseLerp(max, 0, offset);
|
||||
UpdateValue(value);
|
||||
}
|
||||
public override void Update() {
|
||||
if (!slider.isDragger) { return; }
|
||||
float differ = Screen.height - UITool.GetMousePosition().y - slider.pointerPosition;
|
||||
float offset = differ + slider.originalPosition;
|
||||
float max = slider.Container.resolvedStyle.height;
|
||||
float value = Mathf.InverseLerp(max, 0, offset);
|
||||
UpdateValue(value);
|
||||
}
|
||||
public override void UpdateValue(float value, bool send = true) {
|
||||
slider.value = value;
|
||||
if (send) { slider.ValueChanged?.Invoke(value); }
|
||||
slider.Tracker.style.height = Length.Percent(value * 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0721892edd97c594d80af856cbf293c8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace MuHua {
|
||||
/// <summary>
|
||||
/// 开关
|
||||
/// </summary>
|
||||
public class UIToggle : ModuleUIPanel {
|
||||
/// <summary> 值改变时 </summary>
|
||||
public event Action<bool> ValueChanged;
|
||||
|
||||
public bool value;// 当前值
|
||||
|
||||
/// <summary> 标题 </summary>
|
||||
public string title {
|
||||
get => Title.text;
|
||||
set => Title.text = value;
|
||||
}
|
||||
|
||||
public Label Title => Q<Label>("Title");
|
||||
public VisualElement Input => Q<VisualElement>("Input");
|
||||
public VisualElement Check => Q<VisualElement>("Check");
|
||||
|
||||
public UIToggle(VisualElement element) : base(element) {
|
||||
Input.RegisterCallback<ClickEvent>(evt => UpdateValue(!value));
|
||||
}
|
||||
/// <summary> 更新值 </summary>
|
||||
public void UpdateValue(bool value, bool send = true) {
|
||||
this.value = value;
|
||||
Check.EnableInClassList("toggle-check-hide", !value);
|
||||
if (send) { ValueChanged?.Invoke(value); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d9f9369fdae61a42ba2cc2d4a52b2ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,64 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace MuHua {
|
||||
/// <summary>
|
||||
/// 悬浮窗口
|
||||
/// </summary>
|
||||
public abstract class UIWindow : ModuleUIPanel {
|
||||
/// <summary> 绑定的画布 </summary>
|
||||
public readonly VisualElement canvas;
|
||||
|
||||
private bool isDownMove;
|
||||
private Vector3 pointerPosition;
|
||||
private Vector3 originalPosition;
|
||||
|
||||
public VisualElement Window => Q<VisualElement>("Window");
|
||||
public VisualElement Top => Q<VisualElement>("Top");
|
||||
public VisualElement Container => Q<VisualElement>("Container");
|
||||
|
||||
public Label Title => Q<Label>("Title");
|
||||
public VisualElement Close => Q<VisualElement>("Close");
|
||||
|
||||
public UIWindow(VisualElement element, VisualElement canvas) : base(element) {
|
||||
this.canvas = canvas;
|
||||
|
||||
Top.RegisterCallback<PointerDownEvent>(TopDown);
|
||||
canvas.RegisterCallback<PointerUpEvent>((evt) => isDownMove = false);
|
||||
canvas.RegisterCallback<PointerLeaveEvent>((evt) => isDownMove = false);
|
||||
|
||||
Close.RegisterCallback<ClickEvent>((evt) => SetActive(false));
|
||||
}
|
||||
|
||||
/// <summary> 按下Top </summary>
|
||||
private void TopDown(PointerDownEvent evt) {
|
||||
isDownMove = true;
|
||||
pointerPosition = UITool.GetMousePosition();
|
||||
originalPosition = Window.transform.position;
|
||||
}
|
||||
|
||||
/// <summary> 设置活动状态 </summary>
|
||||
public virtual void SetActive(bool active) {
|
||||
Window.EnableInClassList("window-hidden", !active);
|
||||
}
|
||||
|
||||
/// <summary> 更新状态 </summary>
|
||||
public virtual void Update() {
|
||||
if (!isDownMove) { return; }
|
||||
Vector3 mousePosition = UITool.GetMousePosition();
|
||||
Vector3 offset = mousePosition - pointerPosition;
|
||||
Vector3 position = originalPosition + new Vector3(offset.x, -offset.y);
|
||||
|
||||
float width = canvas.resolvedStyle.width - Window.resolvedStyle.width;
|
||||
float height = canvas.resolvedStyle.height - Window.resolvedStyle.height;
|
||||
position.x = Mathf.Clamp(position.x, 0, width);
|
||||
position.y = Mathf.Clamp(position.y, 0, height);
|
||||
|
||||
Window.transform.position = position;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8db6302b07dcf8649b966f15c6fad581
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "MuHua.UITool",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:df380645f10b7bc4b97d4f5eb6303d95"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6206345d516a2bb4a821a7ee90e1b5d5
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 365591f97ebb2f04fa0710be14bb3185
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58b60911870bc444380272f94925d072
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "muhua-ui-tool",
|
||||
"version": "1.0.0",
|
||||
"displayName": "MuHua UITool",
|
||||
"description": "\u57fa\u4e8eUI Toolkit\u7684\u6269\u5c55\u5de5\u5177\u5305",
|
||||
"author": {
|
||||
"name": "MuHua",
|
||||
"email": "muhua233@qq.com"
|
||||
},
|
||||
"type": "tool",
|
||||
"samples": [
|
||||
{
|
||||
"displayName": "Example",
|
||||
"description": "An example showing how to use the UITool.",
|
||||
"path": "Samples~"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"com.unity.shadergraph": "14.0.11",
|
||||
"com.unity.render-pipelines.core": "14.0.11"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e89edc7869c0e2643ac846f99ac5928c
|
||||
PackageManifestImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,43 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"com.unity.collab-proxy": "2.8.2",
|
||||
"com.unity.feature.development": "1.0.1",
|
||||
"com.unity.textmeshpro": "3.0.6",
|
||||
"com.unity.timeline": "1.7.6",
|
||||
"com.unity.toolchain.win-x86_64-linux-x86_64": "2.0.10",
|
||||
"com.unity.ugui": "1.0.0",
|
||||
"com.unity.visualscripting": "1.9.4",
|
||||
"muhua-tools": "https://github.com/MuHua-123/MuHua-Core.git?path=Packages/Tools",
|
||||
"com.unity.modules.ai": "1.0.0",
|
||||
"com.unity.modules.androidjni": "1.0.0",
|
||||
"com.unity.modules.animation": "1.0.0",
|
||||
"com.unity.modules.assetbundle": "1.0.0",
|
||||
"com.unity.modules.audio": "1.0.0",
|
||||
"com.unity.modules.cloth": "1.0.0",
|
||||
"com.unity.modules.director": "1.0.0",
|
||||
"com.unity.modules.imageconversion": "1.0.0",
|
||||
"com.unity.modules.imgui": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0",
|
||||
"com.unity.modules.particlesystem": "1.0.0",
|
||||
"com.unity.modules.physics": "1.0.0",
|
||||
"com.unity.modules.physics2d": "1.0.0",
|
||||
"com.unity.modules.screencapture": "1.0.0",
|
||||
"com.unity.modules.terrain": "1.0.0",
|
||||
"com.unity.modules.terrainphysics": "1.0.0",
|
||||
"com.unity.modules.tilemap": "1.0.0",
|
||||
"com.unity.modules.ui": "1.0.0",
|
||||
"com.unity.modules.uielements": "1.0.0",
|
||||
"com.unity.modules.umbra": "1.0.0",
|
||||
"com.unity.modules.unityanalytics": "1.0.0",
|
||||
"com.unity.modules.unitywebrequest": "1.0.0",
|
||||
"com.unity.modules.unitywebrequestassetbundle": "1.0.0",
|
||||
"com.unity.modules.unitywebrequestaudio": "1.0.0",
|
||||
"com.unity.modules.unitywebrequesttexture": "1.0.0",
|
||||
"com.unity.modules.unitywebrequestwww": "1.0.0",
|
||||
"com.unity.modules.vehicles": "1.0.0",
|
||||
"com.unity.modules.video": "1.0.0",
|
||||
"com.unity.modules.vr": "1.0.0",
|
||||
"com.unity.modules.wind": "1.0.0",
|
||||
"com.unity.modules.xr": "1.0.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,451 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"com.unity.collab-proxy": {
|
||||
"version": "2.8.2",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.editorcoroutines": {
|
||||
"version": "1.0.0",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.ext.nunit": {
|
||||
"version": "1.0.6",
|
||||
"depth": 2,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.feature.development": {
|
||||
"version": "1.0.1",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.ide.visualstudio": "2.0.22",
|
||||
"com.unity.ide.rider": "3.0.28",
|
||||
"com.unity.ide.vscode": "1.2.5",
|
||||
"com.unity.editorcoroutines": "1.0.0",
|
||||
"com.unity.performance.profile-analyzer": "1.2.2",
|
||||
"com.unity.test-framework": "1.1.33",
|
||||
"com.unity.testtools.codecoverage": "1.2.5"
|
||||
}
|
||||
},
|
||||
"com.unity.ide.rider": {
|
||||
"version": "3.0.28",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.ext.nunit": "1.0.6"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.ide.visualstudio": {
|
||||
"version": "2.0.22",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.test-framework": "1.1.9"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.ide.vscode": {
|
||||
"version": "1.2.5",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.performance.profile-analyzer": {
|
||||
"version": "1.2.2",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.render-pipelines.core": {
|
||||
"version": "14.0.11",
|
||||
"depth": 1,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.ugui": "1.0.0",
|
||||
"com.unity.modules.physics": "1.0.0",
|
||||
"com.unity.modules.terrain": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.searcher": {
|
||||
"version": "4.9.2",
|
||||
"depth": 2,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.settings-manager": {
|
||||
"version": "2.0.1",
|
||||
"depth": 2,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.shadergraph": {
|
||||
"version": "14.0.11",
|
||||
"depth": 1,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.render-pipelines.core": "14.0.11",
|
||||
"com.unity.searcher": "4.9.2"
|
||||
}
|
||||
},
|
||||
"com.unity.sysroot": {
|
||||
"version": "2.0.10",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.sysroot.linux-x86_64": {
|
||||
"version": "2.0.9",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.sysroot": "2.0.10"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.test-framework": {
|
||||
"version": "1.1.33",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.ext.nunit": "1.0.6",
|
||||
"com.unity.modules.imgui": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.testtools.codecoverage": {
|
||||
"version": "1.2.5",
|
||||
"depth": 1,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.test-framework": "1.0.16",
|
||||
"com.unity.settings-manager": "1.0.1"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.textmeshpro": {
|
||||
"version": "3.0.6",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.ugui": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.timeline": {
|
||||
"version": "1.7.6",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.modules.director": "1.0.0",
|
||||
"com.unity.modules.animation": "1.0.0",
|
||||
"com.unity.modules.audio": "1.0.0",
|
||||
"com.unity.modules.particlesystem": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.toolchain.win-x86_64-linux-x86_64": {
|
||||
"version": "2.0.10",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.sysroot": "2.0.10",
|
||||
"com.unity.sysroot.linux-x86_64": "2.0.9"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"com.unity.ugui": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.ui": "1.0.0",
|
||||
"com.unity.modules.imgui": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.visualscripting": {
|
||||
"version": "1.9.4",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
"com.unity.ugui": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0"
|
||||
},
|
||||
"url": "https://packages.unity.cn"
|
||||
},
|
||||
"muhua-tools": {
|
||||
"version": "https://github.com/MuHua-123/MuHua-Core.git?path=Packages/Tools",
|
||||
"depth": 0,
|
||||
"source": "git",
|
||||
"dependencies": {},
|
||||
"hash": "1e26adfb03416178e47aa5473b74dd58533fab9e"
|
||||
},
|
||||
"muhua-ui-tool": {
|
||||
"version": "file:UITool",
|
||||
"depth": 0,
|
||||
"source": "embedded",
|
||||
"dependencies": {
|
||||
"com.unity.shadergraph": "14.0.11",
|
||||
"com.unity.render-pipelines.core": "14.0.11"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.ai": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.androidjni": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.animation": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.assetbundle": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.audio": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.cloth": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.physics": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.director": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.audio": "1.0.0",
|
||||
"com.unity.modules.animation": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.imageconversion": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.imgui": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.jsonserialize": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.particlesystem": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.physics": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.physics2d": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.screencapture": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.imageconversion": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.subsystems": {
|
||||
"version": "1.0.0",
|
||||
"depth": 1,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.jsonserialize": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.terrain": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.terrainphysics": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.physics": "1.0.0",
|
||||
"com.unity.modules.terrain": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.tilemap": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.physics2d": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.ui": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.uielements": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.ui": "1.0.0",
|
||||
"com.unity.modules.imgui": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.umbra": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.unityanalytics": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.unitywebrequest": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.unitywebrequest": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.unitywebrequestassetbundle": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.assetbundle": "1.0.0",
|
||||
"com.unity.modules.unitywebrequest": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.unitywebrequestaudio": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.unitywebrequest": "1.0.0",
|
||||
"com.unity.modules.audio": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.unitywebrequesttexture": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.unitywebrequest": "1.0.0",
|
||||
"com.unity.modules.imageconversion": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.unitywebrequestwww": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.unitywebrequest": "1.0.0",
|
||||
"com.unity.modules.unitywebrequestassetbundle": "1.0.0",
|
||||
"com.unity.modules.unitywebrequestaudio": "1.0.0",
|
||||
"com.unity.modules.audio": "1.0.0",
|
||||
"com.unity.modules.assetbundle": "1.0.0",
|
||||
"com.unity.modules.imageconversion": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.vehicles": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.physics": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.video": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.audio": "1.0.0",
|
||||
"com.unity.modules.ui": "1.0.0",
|
||||
"com.unity.modules.unitywebrequest": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.vr": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.jsonserialize": "1.0.0",
|
||||
"com.unity.modules.physics": "1.0.0",
|
||||
"com.unity.modules.xr": "1.0.0"
|
||||
}
|
||||
},
|
||||
"com.unity.modules.wind": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {}
|
||||
},
|
||||
"com.unity.modules.xr": {
|
||||
"version": "1.0.0",
|
||||
"depth": 0,
|
||||
"source": "builtin",
|
||||
"dependencies": {
|
||||
"com.unity.modules.physics": "1.0.0",
|
||||
"com.unity.modules.jsonserialize": "1.0.0",
|
||||
"com.unity.modules.subsystems": "1.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user