Compare commits
8 Commits
c17af4d74b
...
7007bfaf19
| Author | SHA1 | Date | |
|---|---|---|---|
| 7007bfaf19 | |||
| 539b592959 | |||
| 31fc996021 | |||
| 44b160d069 | |||
| ccad83226f | |||
| 165339172a | |||
| 9be153994f | |||
| f4a07224aa |
@@ -11,6 +11,24 @@ public class InputMenu : InputControl {
|
|||||||
|
|
||||||
private UIMenuPanel menu;
|
private UIMenuPanel menu;
|
||||||
|
|
||||||
|
private void Start() {
|
||||||
|
ShortcutMenu.I.Add("测试1/测试11", () => { Debug.Log("测试1/测试11"); });
|
||||||
|
ShortcutMenu.I.Add("测试1/测试12", () => { Debug.Log("测试1/测试12"); });
|
||||||
|
|
||||||
|
ShortcutMenu.I.Add("删除测试5", () => {
|
||||||
|
ShortcutMenu.I.Remove("测试5");
|
||||||
|
});
|
||||||
|
ShortcutMenu.I.Add("删除测试51", () => {
|
||||||
|
ShortcutMenu.I.Remove("测试5/测试51");
|
||||||
|
});
|
||||||
|
ShortcutMenu.I.Add("删除测试52", () => {
|
||||||
|
ShortcutMenu.I.Remove("测试5/测试52");
|
||||||
|
});
|
||||||
|
|
||||||
|
ShortcutMenu.I.Add("测试5/测试51", () => { Debug.Log("测试51"); });
|
||||||
|
ShortcutMenu.I.Add("测试5/测试52", () => { Debug.Log("测试52"); });
|
||||||
|
}
|
||||||
|
|
||||||
protected override void ModuleInput_OnInputMode(InputMode mode) {
|
protected override void ModuleInput_OnInputMode(InputMode mode) {
|
||||||
// throw new System.NotImplementedException();
|
// throw new System.NotImplementedException();
|
||||||
}
|
}
|
||||||
@@ -19,16 +37,11 @@ public class InputMenu : InputControl {
|
|||||||
/// <summary> 鼠标左键 </summary>
|
/// <summary> 鼠标左键 </summary>
|
||||||
public void OnMouseLeft(InputValue inputValue) {
|
public void OnMouseLeft(InputValue inputValue) {
|
||||||
if (inputValue.isPressed) return;
|
if (inputValue.isPressed) return;
|
||||||
UIShortcutMenu.I.Close();
|
ShortcutMenu.I.Close();
|
||||||
}
|
}
|
||||||
/// <summary> 鼠标右键 </summary>
|
/// <summary> 鼠标右键 </summary>
|
||||||
public void OnMouseRight(InputValue inputValue) {
|
public void OnMouseRight(InputValue inputValue) {
|
||||||
UIShortcutMenu.I.Add("测试1/测试11", () => { Debug.Log("测试1/测试11"); });
|
ShortcutMenu.I.Open();
|
||||||
UIShortcutMenu.I.Add("测试1/测试12", () => { Debug.Log("测试1/测试12"); });
|
|
||||||
|
|
||||||
UIShortcutMenu.I.Add("测试2", () => { Debug.Log("测试2"); });
|
|
||||||
|
|
||||||
UIShortcutMenu.I.Open();
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
using MuHua;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// SliderInputH - Panel
|
|
||||||
/// </summary>
|
|
||||||
public class UISliderInputH : ModuleUIPanel {
|
|
||||||
|
|
||||||
public float value;
|
|
||||||
public Vector2 range = new Vector2(1, 1);
|
|
||||||
public UISliderH slider;
|
|
||||||
public event Action<float> ValueChanged;
|
|
||||||
|
|
||||||
public VisualElement Slider => Q<VisualElement>("Slider");
|
|
||||||
public UIFloatField FloatField => Q<UIFloatField>("UIFloatField");
|
|
||||||
|
|
||||||
public UISliderInputH(VisualElement element, VisualElement canvas) : base(element) {
|
|
||||||
slider = new UISliderH(element, canvas);
|
|
||||||
|
|
||||||
slider.ValueChanged += Slider_ValueChanged;
|
|
||||||
FloatField.RegisterCallback<ChangeEvent<float>>(FloatField_ValueChanged);
|
|
||||||
}
|
|
||||||
private void Slider_ValueChanged(float obj) {
|
|
||||||
value = Mathf.Lerp(range.x, range.y, obj);
|
|
||||||
FloatField.SetValueWithoutNotify(value);
|
|
||||||
ValueChanged?.Invoke(value);
|
|
||||||
}
|
|
||||||
private void FloatField_ValueChanged(ChangeEvent<float> obj) {
|
|
||||||
value = Mathf.Clamp(obj.newValue, range.x, range.y);
|
|
||||||
float scale = Mathf.InverseLerp(range.x, range.y, value);
|
|
||||||
slider.UpdateValue(scale, false);
|
|
||||||
ValueChanged?.Invoke(value);
|
|
||||||
}
|
|
||||||
public void Update() {
|
|
||||||
slider.Update();
|
|
||||||
}
|
|
||||||
/// <summary> 更新值 </summary>
|
|
||||||
public void UpdateValue(float value) {
|
|
||||||
this.value = Mathf.Clamp(range.x, range.y, value);
|
|
||||||
float scale = Mathf.InverseLerp(range.x, range.y, value);
|
|
||||||
slider.UpdateValue(scale, false);
|
|
||||||
FloatField.SetValueWithoutNotify(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
using MuHua;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Vector2 - Panel
|
|
||||||
/// </summary>
|
|
||||||
public class UIVector2 : ModuleUIPanel {
|
|
||||||
|
|
||||||
public bool isLock;
|
|
||||||
public Vector2 value;
|
|
||||||
public UISliderInputH sliderX;
|
|
||||||
public UISliderInputH sliderY;
|
|
||||||
public event Action<Vector2, bool> ValueChanged;
|
|
||||||
|
|
||||||
public Button Lock => Q<Button>("Lock");
|
|
||||||
public VisualElement SliderX => Q<VisualElement>("SliderInputX");
|
|
||||||
public VisualElement SliderY => Q<VisualElement>("SliderInputY");
|
|
||||||
|
|
||||||
public UIVector2(VisualElement element, VisualElement canvas) : base(element) {
|
|
||||||
sliderX = new UISliderInputH(SliderX, canvas);
|
|
||||||
sliderY = new UISliderInputH(SliderY, canvas);
|
|
||||||
|
|
||||||
Lock.clicked += Lock_clicked;
|
|
||||||
sliderX.ValueChanged += SliderX_ValueChanged;
|
|
||||||
sliderY.ValueChanged += SliderY_ValueChanged;
|
|
||||||
}
|
|
||||||
private void Lock_clicked() {
|
|
||||||
isLock = !isLock;
|
|
||||||
Lock.EnableInClassList("dashboard-button-s", isLock);
|
|
||||||
if (isLock) { value.y = value.x; sliderY.UpdateValue(value.x); }
|
|
||||||
ValueChanged?.Invoke(value, isLock);
|
|
||||||
}
|
|
||||||
private void SliderX_ValueChanged(float obj) {
|
|
||||||
value.x = obj;
|
|
||||||
if (isLock) { value.y = obj; sliderY.UpdateValue(obj); }
|
|
||||||
ValueChanged?.Invoke(value, isLock);
|
|
||||||
}
|
|
||||||
private void SliderY_ValueChanged(float obj) {
|
|
||||||
value.y = obj;
|
|
||||||
if (isLock) { value.x = obj; sliderX.UpdateValue(obj); }
|
|
||||||
ValueChanged?.Invoke(value, isLock);
|
|
||||||
}
|
|
||||||
public void Update() {
|
|
||||||
sliderX.Update();
|
|
||||||
sliderY.Update();
|
|
||||||
}
|
|
||||||
/// <summary> 更新值 </summary>
|
|
||||||
public void UpdateValue(Vector2 value, bool isLock) {
|
|
||||||
this.value = value;
|
|
||||||
this.isLock = isLock;
|
|
||||||
sliderX.UpdateValue(value.x);
|
|
||||||
sliderY.UpdateValue(value.y);
|
|
||||||
Lock.EnableInClassList("dashboard-button-s", isLock);
|
|
||||||
}
|
|
||||||
/// <summary> 设置范围 </summary>
|
|
||||||
public void Settings(Vector2 range) {
|
|
||||||
sliderX.range = range;
|
|
||||||
sliderY.range = range;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
using MuHua;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Vector3 - Panel
|
|
||||||
/// </summary>
|
|
||||||
public class UIVector3 : ModuleUIPanel {
|
|
||||||
|
|
||||||
public Vector3 value;
|
|
||||||
public UISliderInputH sliderX;
|
|
||||||
public UISliderInputH sliderY;
|
|
||||||
public UISliderInputH sliderZ;
|
|
||||||
public event Action<Vector3> ValueChanged;
|
|
||||||
|
|
||||||
public VisualElement SliderInputX => Q<VisualElement>("SliderInputX");
|
|
||||||
public VisualElement SliderInputY => Q<VisualElement>("SliderInputY");
|
|
||||||
public VisualElement SliderInputZ => Q<VisualElement>("SliderInputZ");
|
|
||||||
|
|
||||||
public UIVector3(VisualElement element, VisualElement canvas) : base(element) {
|
|
||||||
sliderX = new UISliderInputH(SliderInputX, canvas);
|
|
||||||
sliderY = new UISliderInputH(SliderInputY, canvas);
|
|
||||||
sliderZ = new UISliderInputH(SliderInputZ, canvas);
|
|
||||||
|
|
||||||
sliderX.ValueChanged += SliderX_ValueChanged;
|
|
||||||
sliderY.ValueChanged += SliderY_ValueChanged;
|
|
||||||
sliderZ.ValueChanged += SliderZ_ValueChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SliderX_ValueChanged(float obj) {
|
|
||||||
value.x = obj;
|
|
||||||
ValueChanged?.Invoke(value);
|
|
||||||
}
|
|
||||||
private void SliderY_ValueChanged(float obj) {
|
|
||||||
value.y = obj;
|
|
||||||
ValueChanged?.Invoke(value);
|
|
||||||
}
|
|
||||||
private void SliderZ_ValueChanged(float obj) {
|
|
||||||
value.z = obj;
|
|
||||||
ValueChanged?.Invoke(value);
|
|
||||||
}
|
|
||||||
public void Update() {
|
|
||||||
sliderX.Update();
|
|
||||||
sliderY.Update();
|
|
||||||
sliderZ.Update();
|
|
||||||
}
|
|
||||||
/// <summary> 更新值 </summary>
|
|
||||||
public void UpdateValue(Vector3 value) {
|
|
||||||
this.value = value;
|
|
||||||
sliderX.UpdateValue(value.x);
|
|
||||||
sliderY.UpdateValue(value.y);
|
|
||||||
sliderZ.UpdateValue(value.z);
|
|
||||||
}
|
|
||||||
/// <summary> 设置范围 </summary>
|
|
||||||
public void Settings(Vector2 range) {
|
|
||||||
sliderX.range = range;
|
|
||||||
sliderY.range = range;
|
|
||||||
sliderZ.range = range;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,113 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
using UnityEngine.Video;
|
|
||||||
using MuHua;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 视频播放控件
|
|
||||||
/// </summary>
|
|
||||||
public class UIVideoPlayPanel : ModuleUIPanel {
|
|
||||||
private float showTime;
|
|
||||||
private bool isDownSlider;
|
|
||||||
private Action fullAction;
|
|
||||||
private RenderTexture renderTexture;
|
|
||||||
private VideoPlayer videoPlayer;
|
|
||||||
private UISliderH slider;
|
|
||||||
|
|
||||||
private VisualElement VideoView => element.Q<VisualElement>("VideoView");
|
|
||||||
private VisualElement VideoController => element.Q<VisualElement>("VideoController");
|
|
||||||
private VisualElement Slider => element.Q<VisualElement>("Slider");
|
|
||||||
private Label Time => element.Q<Label>("Time");
|
|
||||||
private Button Play => element.Q<Button>("Play");
|
|
||||||
private Button Pause => element.Q<Button>("Pause");
|
|
||||||
private Button FullScreen => element.Q<Button>("FullScreen");
|
|
||||||
|
|
||||||
public UIVideoPlayPanel(VisualElement element, VisualElement canvas, VideoPlayer videoPlayer, Action fullAction = null) : base(element) {
|
|
||||||
this.videoPlayer = videoPlayer;
|
|
||||||
this.fullAction = fullAction;
|
|
||||||
|
|
||||||
int width = (int)element.parent.resolvedStyle.width;
|
|
||||||
int height = (int)element.parent.resolvedStyle.height;
|
|
||||||
renderTexture = new RenderTexture(width, height, 0);
|
|
||||||
Background background = Background.FromRenderTexture(renderTexture);
|
|
||||||
VideoView.style.backgroundImage = new StyleBackground(background);
|
|
||||||
|
|
||||||
Play.clicked += Play_clicked;
|
|
||||||
Pause.clicked += Pause_clicked;
|
|
||||||
FullScreen.clicked += FullScreen_clicked;
|
|
||||||
|
|
||||||
VideoView.RegisterCallback<PointerDownEvent>((evt) => showTime = 5);
|
|
||||||
VideoController.RegisterCallback<PointerDownEvent>((evt) => showTime = 5);
|
|
||||||
|
|
||||||
Slider.RegisterCallback<PointerDownEvent>((evt) => isDownSlider = true);
|
|
||||||
Slider.RegisterCallback<PointerUpEvent>((evt) => isDownSlider = false);
|
|
||||||
Slider.RegisterCallback<PointerLeaveEvent>((evt) => isDownSlider = false);
|
|
||||||
|
|
||||||
slider = new UISliderH(element, canvas);
|
|
||||||
slider.ValueChanged += Slider_SlidingValueChanged;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> 启用 </summary>
|
|
||||||
public void Enable(string url) {
|
|
||||||
videoPlayer.url = url; Enable();
|
|
||||||
}
|
|
||||||
/// <summary> 启用 </summary>
|
|
||||||
public void Enable() {
|
|
||||||
UpdateRenderTexture();
|
|
||||||
videoPlayer.targetTexture = renderTexture;
|
|
||||||
if (videoPlayer.isPlaying) { Play_clicked(); }
|
|
||||||
else { Pause_clicked(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> 更新 </summary>
|
|
||||||
public void Update() {
|
|
||||||
if (videoPlayer == null) { return; }
|
|
||||||
showTime -= UnityEngine.Time.deltaTime;
|
|
||||||
Visibility visibility = showTime > 0 ? Visibility.Visible : Visibility.Hidden;
|
|
||||||
VideoController.style.visibility = visibility;
|
|
||||||
//进度条
|
|
||||||
float value = (float)videoPlayer.frame / (float)videoPlayer.frameCount;
|
|
||||||
if (!isDownSlider) { slider.UpdateValue(value, false); }
|
|
||||||
//播放时间
|
|
||||||
string clockTime = TimeSpan.FromSeconds(videoPlayer.clockTime).ToString(@"mm\:ss");
|
|
||||||
string length = TimeSpan.FromSeconds(videoPlayer.length).ToString(@"mm\:ss");
|
|
||||||
Time.text = clockTime + "/" + length;
|
|
||||||
}
|
|
||||||
/// <summary> 播放 </summary>
|
|
||||||
public void Play_clicked() {
|
|
||||||
if (videoPlayer == null) { return; }
|
|
||||||
videoPlayer.Play(); showTime = 5;
|
|
||||||
Play.style.display = DisplayStyle.None;
|
|
||||||
Pause.style.display = DisplayStyle.Flex;
|
|
||||||
}
|
|
||||||
/// <summary> 暂停 </summary>
|
|
||||||
public void Pause_clicked() {
|
|
||||||
if (videoPlayer == null) { return; }
|
|
||||||
videoPlayer.Pause();
|
|
||||||
Play.style.display = DisplayStyle.Flex;
|
|
||||||
Pause.style.display = DisplayStyle.None;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> 更新渲染纹理 </summary>
|
|
||||||
private void UpdateRenderTexture() {
|
|
||||||
int width = (int)element.parent.resolvedStyle.width;
|
|
||||||
int height = (int)element.parent.resolvedStyle.height;
|
|
||||||
if (renderTexture.width == width && renderTexture.height == height) { return; }
|
|
||||||
renderTexture.Release();
|
|
||||||
renderTexture = new RenderTexture(width, height, 0);
|
|
||||||
Background background = Background.FromRenderTexture(renderTexture);
|
|
||||||
VideoView.style.backgroundImage = new StyleBackground(background);
|
|
||||||
}
|
|
||||||
/// <summary> 全屏 </summary>
|
|
||||||
private void FullScreen_clicked() {
|
|
||||||
fullAction?.Invoke();
|
|
||||||
}
|
|
||||||
/// <summary> 进度条更新 </summary>
|
|
||||||
private void Slider_SlidingValueChanged(float obj) {
|
|
||||||
if (videoPlayer == null) { return; }
|
|
||||||
videoPlayer.frame = (long)obj;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
using MuHua;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 消息页面1
|
|
||||||
/// </summary>
|
|
||||||
public class UIMessage1 : ModuleUIPanel {
|
|
||||||
|
|
||||||
public Label Content => Q<Label>("Content");
|
|
||||||
|
|
||||||
public UIMessage1(VisualElement element) : base(element) { }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 设置消息内容
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="active"></param>
|
|
||||||
/// <param name="value"></param>
|
|
||||||
public void Settings(bool active, string value = "") {
|
|
||||||
element.EnableInClassList("document-page-hide", !active);
|
|
||||||
Content.text = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: c0d9cdd61f07fb14a93de29e68c71787
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
using MuHua;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 消息页面2
|
|
||||||
/// </summary>
|
|
||||||
public class UIMessage2 : ModuleUIPanel {
|
|
||||||
|
|
||||||
private Action callback;
|
|
||||||
|
|
||||||
public Label Content => Q<Label>("Content");
|
|
||||||
public Button Button => Q<Button>("Button");
|
|
||||||
|
|
||||||
public UIMessage2(VisualElement element) : base(element) {
|
|
||||||
Button.clicked += () => { callback?.Invoke(); Settings(false); };
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Settings(bool active) {
|
|
||||||
element.EnableInClassList("document-page-hide", !active);
|
|
||||||
callback = null;
|
|
||||||
}
|
|
||||||
public void Settings(bool active, string value = "", Action callback = null) {
|
|
||||||
element.EnableInClassList("document-page-hide", !active);
|
|
||||||
Content.text = value;
|
|
||||||
this.callback = callback;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: d21953f5fb6c41e40b2df711d80a42b3
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
using MuHua;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 消息页面3
|
|
||||||
/// </summary>
|
|
||||||
public class UIMessage3 : ModuleUIPanel {
|
|
||||||
|
|
||||||
private Action callback1;
|
|
||||||
private Action callback2;
|
|
||||||
|
|
||||||
public Label Content => Q<Label>("Content");
|
|
||||||
public Button Button1 => Q<Button>("Button1");
|
|
||||||
public Button Button2 => Q<Button>("Button2");
|
|
||||||
|
|
||||||
public UIMessage3(VisualElement element) : base(element) {
|
|
||||||
Button1.clicked += () => { callback1?.Invoke(); Settings(false); };
|
|
||||||
Button2.clicked += () => { callback2?.Invoke(); Settings(false); };
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Settings(bool active, string value = "", Action callback1 = null, Action callback2 = null) {
|
|
||||||
element.EnableInClassList("document-page-hide", !active);
|
|
||||||
Content.text = value;
|
|
||||||
this.callback1 = callback1;
|
|
||||||
this.callback2 = callback2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 496a1fe1e90187b45b931ec732c0bde6
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
public class UIBannerTip : MonoBehaviour
|
|
||||||
{
|
|
||||||
// Start is called before the first frame update
|
|
||||||
void Start()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update is called once per frame
|
|
||||||
void Update()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 7279e9c7234eb6645b7b1e172b70919d
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,132 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
using MuHua;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 指针提示
|
|
||||||
/// </summary>
|
|
||||||
public class UIGuidance : ModuleUIPanel {
|
|
||||||
|
|
||||||
private bool isDown;
|
|
||||||
private Action callback;
|
|
||||||
private Action<bool> ValueChanged;
|
|
||||||
private Vector2 offset;
|
|
||||||
private Vector3 originalPosition;
|
|
||||||
private Vector3 pointerPosition;
|
|
||||||
private VisualElement target;
|
|
||||||
private UIToggle toggle;
|
|
||||||
|
|
||||||
public Label Prompt => Q<Label>("Prompt");
|
|
||||||
public VisualElement Toggle => Q<VisualElement>("Toggle");
|
|
||||||
public VisualElement Button => Q<VisualElement>("Button");
|
|
||||||
public VisualElement Pointer => Q<VisualElement>("Pointer");
|
|
||||||
|
|
||||||
public UIGuidance(VisualElement element) : base(element) {
|
|
||||||
toggle = new UIToggle(Toggle);
|
|
||||||
toggle.ValueChanged += (value) => { ValueChanged?.Invoke(value); };
|
|
||||||
|
|
||||||
Button.RegisterCallback<ClickEvent>(ClickEvent);
|
|
||||||
|
|
||||||
element.RegisterCallback<MouseDownEvent>(MouseDownEvent);
|
|
||||||
element.RegisterCallback<MouseUpEvent>(MouseUpEvent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Update() {
|
|
||||||
#if UNITY_EDITOR
|
|
||||||
if (target == null) { return; }
|
|
||||||
if (isDown) {
|
|
||||||
Vector3 mousePosition = UITool.GetMousePosition();
|
|
||||||
Vector3 differ = new Vector3(mousePosition.x, Screen.height - mousePosition.y) - pointerPosition;
|
|
||||||
|
|
||||||
Pointer.transform.position = originalPosition + differ;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Pointer.transform.position = target.worldBound.position + offset;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (target == null) { return; }
|
|
||||||
Pointer.transform.position = target.worldBound.position + offset;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ClickEvent(ClickEvent evt) {
|
|
||||||
element.EnableInClassList("document-page-hide", true);
|
|
||||||
callback?.Invoke();
|
|
||||||
}
|
|
||||||
private void MouseDownEvent(MouseDownEvent evt) {
|
|
||||||
#if UNITY_EDITOR
|
|
||||||
isDown = true;
|
|
||||||
originalPosition = Pointer.transform.position;
|
|
||||||
Vector3 mousePosition = UITool.GetMousePosition();
|
|
||||||
pointerPosition = new Vector3(mousePosition.x, Screen.height - mousePosition.y);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
private void MouseUpEvent(MouseUpEvent evt) {
|
|
||||||
isDown = false;
|
|
||||||
float x = Pointer.transform.position.x - target.worldBound.position.x;
|
|
||||||
float y = Pointer.transform.position.y - target.worldBound.position.y;
|
|
||||||
Vector3 offset = new Vector3(x, y);
|
|
||||||
Debug.Log(offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> 打开提示 </summary>
|
|
||||||
public void Settings(string content, VisualElement target, Vector2 offset, Action callback) {
|
|
||||||
this.target = target;
|
|
||||||
this.offset = offset;
|
|
||||||
this.callback = callback;
|
|
||||||
Prompt.text = content;
|
|
||||||
element.EnableInClassList("document-page-hide", false);
|
|
||||||
}
|
|
||||||
/// <summary> 设置提示 </summary>
|
|
||||||
public void Settings(bool value, Action<bool> ValueChanged) {
|
|
||||||
this.ValueChanged = ValueChanged;
|
|
||||||
toggle.UpdateValue(value, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 图案页指引
|
|
||||||
/// </summary>
|
|
||||||
public class UIPatternPageGuidance : ModuleUIPanel {
|
|
||||||
|
|
||||||
private bool isNot;
|
|
||||||
|
|
||||||
public VisualElement Top => Q<VisualElement>("Top");
|
|
||||||
public Button Button1 => Top.Q<Button>("Button1");// 创建图案
|
|
||||||
public Button Button4 => Top.Q<Button>("Button4");// 创建元素
|
|
||||||
|
|
||||||
public VisualElement Dashboard => Q<VisualElement>("Dashboard");
|
|
||||||
public VisualElement PatternLibrary => Q<VisualElement>("PatternLibrary");
|
|
||||||
public VisualElement TemplateLibrary => Q<VisualElement>("TemplateLibrary");
|
|
||||||
|
|
||||||
public UIPatternPageGuidance(VisualElement element) : base(element) { }
|
|
||||||
|
|
||||||
public void Guidance1() {
|
|
||||||
if (isNot) { return; }
|
|
||||||
string content = "第一步 点击【创建图案】按钮,即可新建一个空白画板,开始您的设计。";
|
|
||||||
Guidance(content, Button1, new Vector2(140, -55), Guidance2);
|
|
||||||
}
|
|
||||||
public void Guidance2() {
|
|
||||||
string content = "第二步 提供两种创作方式 \n1,选用模板:点击【图案模板】,选择模板后参考其结构与配色,进行纹样重构与创新设计。";
|
|
||||||
Guidance(content, TemplateLibrary, new Vector2(310, 0), Guidance3);
|
|
||||||
}
|
|
||||||
public void Guidance3() {
|
|
||||||
string content = "2,全新创作:点击【创建元素】创建空白图案框,自行选择【图案元素库】内的图案素材进行创新设计。";
|
|
||||||
Guidance(content, Button4, new Vector2(-530, -65), Guidance4);
|
|
||||||
}
|
|
||||||
public void Guidance4() {
|
|
||||||
string content = "导入个人素材:点击【自定义】-【导入素材】,导入后请点击【自定义】刷新以更新显示。";
|
|
||||||
Guidance(content, PatternLibrary, new Vector2(310, 0), Guidance5);
|
|
||||||
}
|
|
||||||
public void Guidance5() {
|
|
||||||
string content = "图案编辑功能:选中图案元素,可调整其颜色、位置、大小、镜像、连续排列等操作。\n画布设置:如设计透明背景的图案,可根据图案色彩风格自定义画板颜色,便于更直观地进行设计。";
|
|
||||||
Guidance(content, Dashboard, new Vector2(-530, 0), null);
|
|
||||||
}
|
|
||||||
public void Guidance(string content, VisualElement visual, Vector3 offset, Action action) {
|
|
||||||
// UIGuidance guidance = ModuleUI.I.popupManager.guidance;
|
|
||||||
// guidance.Settings(content, visual, offset, action);
|
|
||||||
// guidance.Settings(isNot, (value) => { isNot = value; });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 8df138b434ab51f40b134f831376120e
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
using MuHua;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 加载页面
|
|
||||||
/// </summary>
|
|
||||||
public class UILoading : ModuleUIPanel {
|
|
||||||
|
|
||||||
public UISliderH slider;
|
|
||||||
|
|
||||||
public VisualElement Slider => Q<VisualElement>("Slider");
|
|
||||||
|
|
||||||
public UILoading(VisualElement element, VisualElement canvas) : base(element) {
|
|
||||||
slider = new UISliderH(Slider, canvas);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 设置加载进度
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="active"></param>
|
|
||||||
/// <param name="value1"></param>
|
|
||||||
/// <param name="value2"></param>
|
|
||||||
public void Settings(bool active, float value1, string value2) {
|
|
||||||
element.EnableInClassList("document-page-hide", !active);
|
|
||||||
slider.UpdateValue(value1);
|
|
||||||
slider.Title.text = value2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 637e7bc032a4bee4aa936fb481495299
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
using MuHua;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// UI加载管理器
|
|
||||||
/// </summary>
|
|
||||||
public class UILoadManager : ModuleUIPage {
|
|
||||||
|
|
||||||
// public UIProgres progres;
|
|
||||||
|
|
||||||
public override VisualElement Element => root.Q<VisualElement>("Popup");
|
|
||||||
|
|
||||||
public VisualElement PopupDialog => Q<VisualElement>("PopupDialog");
|
|
||||||
|
|
||||||
private void Awake() {
|
|
||||||
// progres = new UIProgres(PopupDialog);
|
|
||||||
}
|
|
||||||
private void OnDestroy() {
|
|
||||||
// config.Release();
|
|
||||||
// configMaterial.Release();
|
|
||||||
// equipmentSelection.Release();
|
|
||||||
// paramrInput.Release();
|
|
||||||
}
|
|
||||||
private void Update() {
|
|
||||||
// config.Update();
|
|
||||||
// configMaterial.Update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 2da9aad7a772f434080f14bd479de19c
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
using MuHua;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// UI弹出管理器
|
|
||||||
/// </summary>
|
|
||||||
public class UIPopupManager : ModuleUISingle<UIPopupManager> {
|
|
||||||
|
|
||||||
public override VisualElement Element => root.Q<VisualElement>("Popup");
|
|
||||||
|
|
||||||
public VisualElement PopupDialog => Q<VisualElement>("PopupDialog");
|
|
||||||
|
|
||||||
protected override void Awake() => NoReplace(false);
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 58ce28d05656cfd498fc2555599e349c
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,169 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
using MuHua;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// UI快捷菜单
|
|
||||||
/// </summary>
|
|
||||||
public class UIShortcutMenu : ModuleUISingle<UIShortcutMenu> {
|
|
||||||
/// <summary> 菜单模板 </summary>
|
|
||||||
public VisualTreeAsset menuTreeAsset;
|
|
||||||
/// <summary> 项目模板 </summary>
|
|
||||||
public VisualTreeAsset itemTreeAsset;
|
|
||||||
|
|
||||||
/// <summary> 数据列表 </summary>
|
|
||||||
public List<DataMenuItem> datas = new List<DataMenuItem>();
|
|
||||||
/// <summary> 控件列表 </summary>
|
|
||||||
public static List<UIControl> controls = new List<UIControl>();
|
|
||||||
|
|
||||||
public override VisualElement Element => root.Q<VisualElement>("ShortcutMenu");
|
|
||||||
|
|
||||||
protected override void Awake() => NoReplace(false);
|
|
||||||
|
|
||||||
private void Update() => controls.ForEach(control => control.Update());
|
|
||||||
|
|
||||||
private void OnDestroy() => controls.ForEach(control => control.Dispose());
|
|
||||||
|
|
||||||
/// <summary> 打开菜单 </summary>
|
|
||||||
public void Open() {
|
|
||||||
Close();
|
|
||||||
Vector3 position = UITool.GetMousePosition(Element);
|
|
||||||
UIMenuPanel menuPanel = Create();
|
|
||||||
menuPanel.Settings(position, datas);
|
|
||||||
}
|
|
||||||
/// <summary> 关闭菜单 </summary>
|
|
||||||
public void Close() {
|
|
||||||
controls.ForEach(control => control.Dispose());
|
|
||||||
controls.Clear();
|
|
||||||
Element.Clear();
|
|
||||||
}
|
|
||||||
/// <summary> 创建子菜单 </summary>
|
|
||||||
public UIMenuPanel Create() {
|
|
||||||
// 创建菜单元素
|
|
||||||
VisualElement element = menuTreeAsset.Instantiate();
|
|
||||||
element.EnableInClassList("menu", true);
|
|
||||||
Element.Add(element);
|
|
||||||
UIMenuPanel menuPanel = new UIMenuPanel(element, itemTreeAsset);
|
|
||||||
controls.Add(menuPanel);
|
|
||||||
return menuPanel;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> 添加菜单项(方法) </summary>
|
|
||||||
public void Add(string name, Action callback) {
|
|
||||||
string[] names = name.Split('/');
|
|
||||||
|
|
||||||
List<DataMenuItem> datas = this.datas;
|
|
||||||
for (int i = 0; i < names.Length; i++) {
|
|
||||||
string menu = names[i];
|
|
||||||
DataMenuItem item = datas.Find(obj => obj.name == menu);
|
|
||||||
if (item == null) {
|
|
||||||
item = new DataMenuItem { name = menu };
|
|
||||||
if (i == names.Length - 1) { item.callback = callback; }
|
|
||||||
datas.Add(item);
|
|
||||||
}
|
|
||||||
datas = item.items;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary> 移除菜单项 </summary>
|
|
||||||
public void Remove(string name) {
|
|
||||||
string[] names = name.Split('/');
|
|
||||||
List<DataMenuItem> datas = this.datas;
|
|
||||||
DataMenuItem parent = null;
|
|
||||||
DataMenuItem target = null;
|
|
||||||
|
|
||||||
for (int i = 0; i < names.Length; i++) {
|
|
||||||
string menu = names[i];
|
|
||||||
target = datas.Find(obj => obj.name == menu);
|
|
||||||
if (target == null) return; // 未找到,直接返回
|
|
||||||
if (i == names.Length - 1) {
|
|
||||||
// 找到要移除的项
|
|
||||||
datas.Remove(target);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
parent = target;
|
|
||||||
datas = target.items;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// UI快捷菜单面板
|
|
||||||
/// </summary>
|
|
||||||
public class UIMenuPanel : ModuleUIPanel, UIControl {
|
|
||||||
|
|
||||||
public UIMenuPanel menuPanel;
|
|
||||||
public VisualElement submenu;
|
|
||||||
public ModuleUIItems<UIItem, DataMenuItem> items;
|
|
||||||
|
|
||||||
public VisualElement Container => Q<VisualElement>("Container");
|
|
||||||
|
|
||||||
public UIMenuPanel(VisualElement element, VisualTreeAsset templateAsset) : base(element) {
|
|
||||||
items = new ModuleUIItems<UIItem, DataMenuItem>(Container, templateAsset,
|
|
||||||
(data, element) => new UIItem(data, element, this));
|
|
||||||
}
|
|
||||||
public void Update() {
|
|
||||||
// throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
public void Dispose() {
|
|
||||||
items.Release();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Settings(Vector3 position, List<DataMenuItem> datas) {
|
|
||||||
items.Create(datas);
|
|
||||||
element.transform.position = position;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> 打开子菜单 </summary>
|
|
||||||
public void Open(VisualElement submenu, List<DataMenuItem> datas) {
|
|
||||||
if (this.submenu == submenu) { return; }
|
|
||||||
// 更新子菜单
|
|
||||||
this.submenu = submenu;
|
|
||||||
if (menuPanel == null) { menuPanel = UIShortcutMenu.I.Create(); }
|
|
||||||
float x = submenu.worldBound.position.x + submenu.resolvedStyle.width;
|
|
||||||
float y = submenu.worldBound.position.y - 5;
|
|
||||||
Vector3 position = new Vector3(x, y, 0);
|
|
||||||
menuPanel.Settings(position, datas);
|
|
||||||
bool isEnable = datas != null && datas.Count > 0;
|
|
||||||
menuPanel.OpenSubmenu(isEnable);
|
|
||||||
}
|
|
||||||
public void OpenSubmenu(bool open) {
|
|
||||||
element.EnableInClassList("menu-hide", !open);
|
|
||||||
menuPanel?.OpenSubmenu(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary> UI项目 </summary>
|
|
||||||
public class UIItem : ModuleUIItem<DataMenuItem> {
|
|
||||||
public readonly UIMenuPanel parent;
|
|
||||||
|
|
||||||
public Label Name => element.Q<Label>("Name");
|
|
||||||
public VisualElement Arrow => element.Q<VisualElement>("Arrow");
|
|
||||||
|
|
||||||
public UIItem(DataMenuItem value, VisualElement element, UIMenuPanel parent) : base(value, element) {
|
|
||||||
this.parent = parent;
|
|
||||||
Name.text = value.name;
|
|
||||||
Arrow.EnableInClassList("menu-arrow-hide", value.items == null || value.items.Count == 0);
|
|
||||||
element.RegisterCallback<MouseDownEvent>(MouseDownEvent);
|
|
||||||
element.RegisterCallback<MouseMoveEvent>(MouseMoveEvent);
|
|
||||||
}
|
|
||||||
private void MouseDownEvent(MouseDownEvent evt) {
|
|
||||||
value.callback?.Invoke();
|
|
||||||
UIShortcutMenu.I.Close();
|
|
||||||
}
|
|
||||||
private void MouseMoveEvent(MouseMoveEvent evt) {
|
|
||||||
parent.Open(element, value.items);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/// <summary>
|
|
||||||
/// 菜单项目
|
|
||||||
/// </summary>
|
|
||||||
public class DataMenuItem {
|
|
||||||
/// <summary> 名称 </summary>
|
|
||||||
public string name;
|
|
||||||
/// <summary> 回调 </summary>
|
|
||||||
public Action callback;
|
|
||||||
/// <summary> 子菜单项 </summary>
|
|
||||||
public List<DataMenuItem> items = new List<DataMenuItem>();
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 253123fa56cb88f4e969b587327d3f7f
|
guid: d73f0702f68e73243ab4c6940caafa59
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 06f31db1c09e8a0409a8b3b960a13216
|
guid: 6477bb920cf3e3a4fbaf3e01082e3ae3
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using MuHua;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 快捷菜单
|
||||||
|
/// </summary>
|
||||||
|
public class ShortcutMenu : Module<ShortcutMenu> {
|
||||||
|
/// <summary> 数据列表 </summary>
|
||||||
|
public List<ShortcutMenuItem> menuItems = new List<ShortcutMenuItem>();
|
||||||
|
|
||||||
|
/// <summary> 打开菜单 </summary>
|
||||||
|
public void Open() => UIShortcutMenu.I?.Open();
|
||||||
|
|
||||||
|
/// <summary> 关闭菜单 </summary>
|
||||||
|
public void Close() => UIShortcutMenu.I?.Close();
|
||||||
|
|
||||||
|
/// <summary> 添加菜单项(1级菜单/2级菜单/3级菜单) </summary>
|
||||||
|
public void Add(string name, Action callback) {
|
||||||
|
string[] names = name.Split('/');
|
||||||
|
ShortcutMenuItem item = Find(names[0], menuItems, true);
|
||||||
|
for (int i = 1; i < names.Length; i++) {
|
||||||
|
item = Find(names[i], item.menuItems, true);
|
||||||
|
}
|
||||||
|
item.callback = callback;
|
||||||
|
}
|
||||||
|
/// <summary> 移除菜单项(???/???/子级菜单) </summary>
|
||||||
|
public void Remove(string name) {
|
||||||
|
string[] names = name.Split('/');
|
||||||
|
List<ShortcutMenuItem> menuItems = this.menuItems;
|
||||||
|
ShortcutMenuItem item = Find(names[0], menuItems, false);
|
||||||
|
for (int i = 1; i < names.Length; i++) {
|
||||||
|
if (item == null) return;
|
||||||
|
menuItems = item.menuItems;
|
||||||
|
item = Find(names[i], menuItems, false);
|
||||||
|
}
|
||||||
|
menuItems.Remove(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> 子项目查找 </summary>
|
||||||
|
private ShortcutMenuItem Find(string menu, List<ShortcutMenuItem> menuItems, bool isCreate) {
|
||||||
|
ShortcutMenuItem item = menuItems.Find(obj => obj.name == menu);
|
||||||
|
if (item != null || !isCreate) { return item; }
|
||||||
|
item = new ShortcutMenuItem { name = menu };
|
||||||
|
menuItems.Add(item);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 36d613e41a27e8f40be6e6c05de1aeb1
|
guid: 23732e20aab811a4eba63cc0f810d659
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 快捷菜单项目
|
||||||
|
/// </summary>
|
||||||
|
public class ShortcutMenuItem {
|
||||||
|
/// <summary> 名称 </summary>
|
||||||
|
public string name;
|
||||||
|
/// <summary> 回调 </summary>
|
||||||
|
public Action callback;
|
||||||
|
/// <summary> 子菜单项 </summary>
|
||||||
|
public List<ShortcutMenuItem> menuItems = new List<ShortcutMenuItem>();
|
||||||
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 00c04ca4ef821d0469a77408648f5ff2
|
guid: fac2916b09800194a8389027d4b54ce8
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
using MuHua;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// UI快捷菜单面板
|
||||||
|
/// </summary>
|
||||||
|
public class UIMenuPanel : ModuleUIPanel, UIControl {
|
||||||
|
|
||||||
|
public UIMenuPanel menuPanel;
|
||||||
|
public VisualElement submenu;
|
||||||
|
public ModuleUIItems<UIItem, ShortcutMenuItem> items;
|
||||||
|
|
||||||
|
public VisualElement Container => Q<VisualElement>("Container");
|
||||||
|
|
||||||
|
public UIMenuPanel(VisualElement element, VisualTreeAsset templateAsset) : base(element) {
|
||||||
|
items = new ModuleUIItems<UIItem, ShortcutMenuItem>(Container, templateAsset,
|
||||||
|
(data, element) => new UIItem(data, element, this));
|
||||||
|
}
|
||||||
|
public void Update() {
|
||||||
|
// throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
public void Dispose() {
|
||||||
|
items.Release();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Settings(Vector3 position, List<ShortcutMenuItem> datas) {
|
||||||
|
items.Create(datas);
|
||||||
|
element.transform.position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> 打开子菜单 </summary>
|
||||||
|
public void Open(VisualElement submenu, List<ShortcutMenuItem> datas) {
|
||||||
|
if (this.submenu == submenu) { return; }
|
||||||
|
// 更新子菜单
|
||||||
|
this.submenu = submenu;
|
||||||
|
if (menuPanel == null) { menuPanel = UIShortcutMenu.I.Create(); }
|
||||||
|
float x = submenu.worldBound.position.x + submenu.resolvedStyle.width;
|
||||||
|
float y = submenu.worldBound.position.y - 4;
|
||||||
|
Vector3 position = new Vector3(x, y, 0);
|
||||||
|
menuPanel.Settings(position, datas);
|
||||||
|
bool isEnable = datas != null && datas.Count > 0;
|
||||||
|
menuPanel.OpenSubmenu(isEnable);
|
||||||
|
}
|
||||||
|
public void OpenSubmenu(bool open) {
|
||||||
|
element.EnableInClassList("menu-hide", !open);
|
||||||
|
menuPanel?.OpenSubmenu(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary> UI项目 </summary>
|
||||||
|
public class UIItem : ModuleUIItem<ShortcutMenuItem> {
|
||||||
|
public readonly UIMenuPanel parent;
|
||||||
|
|
||||||
|
public Label Name => element.Q<Label>("Name");
|
||||||
|
public VisualElement Arrow => element.Q<VisualElement>("Arrow");
|
||||||
|
|
||||||
|
public UIItem(ShortcutMenuItem value, VisualElement element, UIMenuPanel parent) : base(value, element) {
|
||||||
|
this.parent = parent;
|
||||||
|
Name.text = value.name;
|
||||||
|
Arrow.EnableInClassList("menu-arrow-hide", value.menuItems == null || value.menuItems.Count == 0);
|
||||||
|
element.RegisterCallback<MouseDownEvent>(MouseDownEvent);
|
||||||
|
element.RegisterCallback<MouseMoveEvent>(MouseMoveEvent);
|
||||||
|
}
|
||||||
|
private void MouseDownEvent(MouseDownEvent evt) {
|
||||||
|
value.callback?.Invoke();
|
||||||
|
UIShortcutMenu.I.Close();
|
||||||
|
}
|
||||||
|
private void MouseMoveEvent(MouseMoveEvent evt) {
|
||||||
|
parent.Open(element, value.menuItems);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: c0898288ac15d9a4e9a82e0d6d36ff17
|
guid: cbfff4523d382a14eb835f39d022b39d
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
using MuHua;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// UI快捷菜单
|
||||||
|
/// </summary>
|
||||||
|
public class UIShortcutMenu : ModuleUISingle<UIShortcutMenu> {
|
||||||
|
/// <summary> 菜单模板 </summary>
|
||||||
|
public VisualTreeAsset MenuPanel;
|
||||||
|
/// <summary> 项目模板 </summary>
|
||||||
|
public VisualTreeAsset MenuTemplate;
|
||||||
|
|
||||||
|
/// <summary> 控件列表 </summary>
|
||||||
|
public static List<UIControl> controls = new List<UIControl>();
|
||||||
|
|
||||||
|
public override VisualElement Element => root.Q<VisualElement>("ShortcutMenu");
|
||||||
|
|
||||||
|
protected override void Awake() => NoReplace(false);
|
||||||
|
|
||||||
|
private void Update() => controls.ForEach(control => control.Update());
|
||||||
|
|
||||||
|
private void OnDestroy() => controls.ForEach(control => control.Dispose());
|
||||||
|
|
||||||
|
/// <summary> 打开菜单 </summary>
|
||||||
|
public void Open() {
|
||||||
|
Close();
|
||||||
|
Vector3 position = UITool.GetMousePosition(Element);
|
||||||
|
UIMenuPanel menuPanel = Create();
|
||||||
|
menuPanel.Settings(position, ShortcutMenu.I.menuItems);
|
||||||
|
}
|
||||||
|
/// <summary> 关闭菜单 </summary>
|
||||||
|
public void Close() {
|
||||||
|
controls.ForEach(control => control.Dispose());
|
||||||
|
controls.Clear();
|
||||||
|
Element.Clear();
|
||||||
|
}
|
||||||
|
/// <summary> 创建子菜单 </summary>
|
||||||
|
public UIMenuPanel Create() {
|
||||||
|
// 创建菜单元素
|
||||||
|
VisualElement element = MenuPanel.Instantiate();
|
||||||
|
element.EnableInClassList("menu", true);
|
||||||
|
Element.Add(element);
|
||||||
|
UIMenuPanel menuPanel = new UIMenuPanel(element, MenuTemplate);
|
||||||
|
controls.Add(menuPanel);
|
||||||
|
return menuPanel;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 1a20e449063139b4ea0d19bd0677c7d1
|
guid: 32fa60a7591d8e149b02b5fac56adfb4
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 5003b2a36519747449a4b6e4d7e5f56e
|
guid: f405743ede2617b4c92bf64862e7402e
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
+6
-11
@@ -1,14 +1,9 @@
|
|||||||
.menu {
|
|
||||||
position: absolute;
|
|
||||||
}
|
|
||||||
|
|
||||||
.menu-hide {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.menu-unit {
|
.menu-unit {
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
align-self: flex-start;
|
align-self: flex-start;
|
||||||
|
flex-grow: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 25px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.menu-unit:hover {
|
.menu-unit:hover {
|
||||||
@@ -21,9 +16,9 @@
|
|||||||
|
|
||||||
.menu-arrow {
|
.menu-arrow {
|
||||||
flex-grow: 0;
|
flex-grow: 0;
|
||||||
height: 30px;
|
height: 25px;
|
||||||
width: 30px;
|
width: 25px;
|
||||||
background-image: url("project://database/Assets/UI%20Toolkit/DefaultTheme/UnityDefaultRuntimeTheme.tss?fileID=-1087164816274819069&guid=05f864e67ee1ecb4bbe67427564d394c&type=3#arrow-right@2x");
|
background-image: url("project://database/Assets/UI%20Toolkit/UnityThemes/UnityDefaultRuntimeTheme.tss?fileID=-1087164816274819069&guid=05f864e67ee1ecb4bbe67427564d394c&type=3#arrow-right@2x");
|
||||||
-unity-background-image-tint-color: rgb(51, 51, 51);
|
-unity-background-image-tint-color: rgb(51, 51, 51);
|
||||||
}
|
}
|
||||||
|
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: e4abceb9650918a419c073e86d8fc3d6
|
guid: 4b1be5340ef21d843bdd2f0eb2375cfe
|
||||||
ScriptedImporter:
|
ScriptedImporter:
|
||||||
internalIDToNameTable: []
|
internalIDToNameTable: []
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
||||||
|
<ui:Template name="Item" src="project://database/Assets/ModuleCore/ModuleUISMenu/UI%20Toolkit/MenuPanel/MenuTemplate.uxml?fileID=9197481963319205126&guid=1ee167986f6e9a840a45450b4b6adfc2&type=3#MenuTemplate" />
|
||||||
|
<Style src="project://database/Assets/ModuleCore/ModuleUISMenu/UI%20Toolkit/MenuPanel/MenuPanel.uss?fileID=7433441132597879392&guid=4b1be5340ef21d843bdd2f0eb2375cfe&type=3#MenuPanel" />
|
||||||
|
<ui:VisualElement name="Container" style="background-color: rgb(255, 255, 255); border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; padding-top: 3px; padding-right: 3px; padding-bottom: 3px; padding-left: 3px; align-self: flex-start; min-width: 150px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-left-color: rgb(51, 51, 51); border-right-color: rgb(51, 51, 51); border-top-color: rgb(51, 51, 51); border-bottom-color: rgb(51, 51, 51);">
|
||||||
|
<ui:Instance template="Item" name="Item" />
|
||||||
|
<ui:Instance template="Item" name="Item" />
|
||||||
|
<ui:Instance template="Item" name="Item" />
|
||||||
|
<ui:Instance template="Item" name="Item" />
|
||||||
|
<ui:Instance template="Item" name="Item" />
|
||||||
|
</ui:VisualElement>
|
||||||
|
</ui:UXML>
|
||||||
+4
-2
@@ -1,7 +1,9 @@
|
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
||||||
<Style src="project://database/Assets/UI%20Toolkit/GamePanel/ShortcutMenu/ShortcutMenu.uss?fileID=7433441132597879392&guid=a53da9fc389948e40ac96af14dd02c10&type=3#ShortcutMenu" />
|
<Style src="project://database/Assets/ModuleCore/ModuleUISMenu/UI%20Toolkit/MenuPanel/MenuPanel.uss?fileID=7433441132597879392&guid=4b1be5340ef21d843bdd2f0eb2375cfe&type=3#MenuPanel" />
|
||||||
<ui:VisualElement class="menu-unit">
|
<ui:VisualElement class="menu-unit">
|
||||||
<ui:Label tabindex="-1" text="Label" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Name" style="-unity-text-align: middle-center; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px; height: 30px;" />
|
<ui:VisualElement style="width: 30px;" />
|
||||||
|
<ui:Label tabindex="-1" text="Label" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Name" style="-unity-text-align: middle-center; margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 10px; padding-right: 10px; padding-bottom: 10px; padding-left: 10px;" />
|
||||||
|
<ui:VisualElement style="flex-grow: 1;" />
|
||||||
<ui:VisualElement name="Arrow" class="menu-arrow" />
|
<ui:VisualElement name="Arrow" class="menu-arrow" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
</ui:UXML>
|
</ui:UXML>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
.menu {
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-hide {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: ed61f5627e04e114eb2c086ae01dc7b4
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
using UnityEditor;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
|
|
||||||
public class TestEditorWindow : EditorWindow {
|
|
||||||
[SerializeField]
|
|
||||||
private VisualTreeAsset m_VisualTreeAsset = default;
|
|
||||||
|
|
||||||
[MenuItem("Window/MuHua/TestEditorWindow")]
|
|
||||||
public static void ShowExample() {
|
|
||||||
TestEditorWindow wnd = GetWindow<TestEditorWindow>();
|
|
||||||
wnd.titleContent = new GUIContent("TestEditorWindow");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void CreateGUI() {
|
|
||||||
// Each editor window contains a root VisualElement object
|
|
||||||
VisualElement root = rootVisualElement;
|
|
||||||
|
|
||||||
// VisualElements objects can contain other VisualElement following a tree hierarchy.
|
|
||||||
VisualElement label = new Label("Hello World! From C#");
|
|
||||||
root.Add(label);
|
|
||||||
|
|
||||||
// Instantiate UXML
|
|
||||||
VisualElement labelFromUXML = m_VisualTreeAsset.Instantiate();
|
|
||||||
root.Add(labelFromUXML);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: ccbcb6aee5874ac4ba30fcb269d7c7ba
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences:
|
|
||||||
- m_VisualTreeAsset: {fileID: 9197481963319205126, guid: d23b67a16b48c2243aabe57056dbfbed, type: 3}
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -186,7 +186,7 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
m_PanelSettings: {fileID: 11400000, guid: 782028a3ae72af7429ad2ecdce684390, type: 2}
|
m_PanelSettings: {fileID: 11400000, guid: 782028a3ae72af7429ad2ecdce684390, type: 2}
|
||||||
m_ParentUI: {fileID: 0}
|
m_ParentUI: {fileID: 0}
|
||||||
sourceAsset: {fileID: 9197481963319205126, guid: 31e24fa07355f6e42841c8f1d0e77e54, type: 3}
|
sourceAsset: {fileID: 9197481963319205126, guid: 42fc25f5fff9d234ea4e7a8b6d1961a8, type: 3}
|
||||||
m_SortingOrder: 0
|
m_SortingOrder: 0
|
||||||
--- !u!4 &670296964
|
--- !u!4 &670296964
|
||||||
Transform:
|
Transform:
|
||||||
@@ -652,7 +652,7 @@ GameObject:
|
|||||||
- component: {fileID: 1922845063}
|
- component: {fileID: 1922845063}
|
||||||
- component: {fileID: 1922845064}
|
- component: {fileID: 1922845064}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: UIMenuManager
|
m_Name: UIShortcutMenu
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<ui:Label tabindex="-1" text="下拉框" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Title" class="dropdown-title" />
|
<ui:Label tabindex="-1" text="下拉框" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Title" class="dropdown-title" />
|
||||||
<ui:VisualElement name="Input" class="dropdown-input">
|
<ui:VisualElement name="Input" class="dropdown-input">
|
||||||
<ui:Label tabindex="-1" text="标签" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Tag" class="dropdown-tag" />
|
<ui:Label tabindex="-1" text="标签" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Tag" class="dropdown-tag" />
|
||||||
<ui:VisualElement name="Icon" class="dropdown-icon" style="background-image: url("project://database/Assets/UI%20Toolkit/DefaultTheme/UnityDefaultRuntimeTheme.tss?fileID=4154780841294389669&guid=05f864e67ee1ecb4bbe67427564d394c&type=3#arrow-down"); -unity-background-image-tint-color: rgb(51, 51, 51);" />
|
<ui:VisualElement name="Icon" class="dropdown-icon" style="background-image: url("project://database/Assets/UI%20Toolkit/UnityThemes/UnityDefaultRuntimeTheme.tss?fileID=4154780841294389669&guid=05f864e67ee1ecb4bbe67427564d394c&type=3#arrow-down"); -unity-background-image-tint-color: rgb(51, 51, 51);" />
|
||||||
<ui:VisualElement name="Positioner" class="dropdown-scrollview" />
|
<ui:VisualElement name="Positioner" class="dropdown-scrollview" />
|
||||||
<ui:VisualElement name="DropdownScrollView" class="scrollview dropdown-scrollview dropdown-hide">
|
<ui:VisualElement name="DropdownScrollView" class="scrollview dropdown-scrollview dropdown-hide">
|
||||||
<ui:VisualElement name="Viewport" class="scrollview-viewport" style="margin-right: 0; margin-bottom: 0; margin-top: 0; margin-left: 0; background-color: rgb(255, 255, 255); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">
|
<ui:VisualElement name="Viewport" class="scrollview-viewport" style="margin-right: 0; margin-bottom: 0; margin-top: 0; margin-left: 0; background-color: rgb(255, 255, 255); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||||
<Style src="project://database/Assets/UI%20Toolkit/Component/Dropdown/Dropdown.uss?fileID=7433441132597879392&guid=1e0657eb9266c804ea6adea1a16c74b2&type=3#Dropdown" />
|
<Style src="project://database/Assets/UI%20Toolkit/Component/Dropdown/Dropdown.uss?fileID=7433441132597879392&guid=1e0657eb9266c804ea6adea1a16c74b2&type=3#Dropdown" />
|
||||||
<ui:Button text="Button" parse-escape-sequences="true" display-tooltip-when-elided="true" class="dropdown-unit">
|
<ui:Button text="Button" parse-escape-sequences="true" display-tooltip-when-elided="true" class="dropdown-unit">
|
||||||
<ui:VisualElement name="Check" class="dropdown-hide" style="width: 20px; height: 20px; background-image: url("project://database/Assets/UI%20Toolkit/DefaultTheme/UnityDefaultRuntimeTheme.tss?fileID=-6090568113533005507&guid=05f864e67ee1ecb4bbe67427564d394c&type=3#check"); -unity-background-image-tint-color: rgb(51, 51, 51);" />
|
<ui:VisualElement name="Check" class="dropdown-hide" style="width: 20px; height: 20px; background-image: url("project://database/Assets/UI%20Toolkit/UnityThemes/UnityDefaultRuntimeTheme.tss?fileID=-6090568113533005507&guid=05f864e67ee1ecb4bbe67427564d394c&type=3#check"); -unity-background-image-tint-color: rgb(51, 51, 51);" />
|
||||||
</ui:Button>
|
</ui:Button>
|
||||||
</ui:UXML>
|
</ui:UXML>
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
|
||||||
<ui:Template name="LoginPage" src="project://database/Assets/UI%20Toolkit/GamePage/LoginPage/LoginPage.uxml?fileID=9197481963319205126&guid=7ebceaef0e3991040bf96648c85589a4&type=3#LoginPage" />
|
<ui:Template name="ShortcutMenu" src="project://database/Assets/ModuleCore/ModuleUISMenu/UI%20Toolkit/ShortcutMenu/ShortcutMenu.uxml?fileID=9197481963319205126&guid=531a74f84d51b5d49a048079629e13e0&type=3#ShortcutMenu" />
|
||||||
<ui:Template name="BannerTip" src="project://database/Assets/UI%20Toolkit/GamePopup/BannerTip/BannerTip.uxml?fileID=9197481963319205126&guid=e4a01fc5cb705fe4c9bedf1d0c5df107&type=3#BannerTip" />
|
|
||||||
<Style src="project://database/Assets/UI%20Toolkit/Document/Document.uss?fileID=7433441132597879392&guid=9205939af30a4394f8f2e34232b27890&type=3#Document" />
|
<Style src="project://database/Assets/UI%20Toolkit/Document/Document.uss?fileID=7433441132597879392&guid=9205939af30a4394f8f2e34232b27890&type=3#Document" />
|
||||||
<ui:Instance template="LoginPage" name="LoginPage" class="document-page document-page-hide" />
|
<ui:Instance template="ShortcutMenu" name="ShortcutMenu" picking-mode="Ignore" class="document-page" />
|
||||||
<ui:VisualElement name="Window" picking-mode="Ignore" class="document-page" style="flex-grow: 1;" />
|
|
||||||
<ui:VisualElement name="Popup" picking-mode="Ignore" class="document-page" style="flex-grow: 1;">
|
|
||||||
<ui:Instance template="BannerTip" name="BannerTip" class="document-page document-page-hide" />
|
|
||||||
</ui:VisualElement>
|
|
||||||
</ui:UXML>
|
</ui:UXML>
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
|
||||||
<ui:Template name="ShortcutMenu" src="project://database/Assets/UI%20Toolkit/GamePanel/ShortcutMenu/ShortcutMenu.uxml?fileID=9197481963319205126&guid=531a74f84d51b5d49a048079629e13e0&type=3#ShortcutMenu" />
|
|
||||||
<Style src="project://database/Assets/UI%20Toolkit/Document/Document.uss?fileID=7433441132597879392&guid=9205939af30a4394f8f2e34232b27890&type=3#Document" />
|
|
||||||
<ui:Instance template="ShortcutMenu" name="ShortcutMenu" picking-mode="Ignore" class="document-page" />
|
|
||||||
</ui:UXML>
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 31e24fa07355f6e42841c8f1d0e77e54
|
|
||||||
ScriptedImporter:
|
|
||||||
internalIDToNameTable: []
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 7b3aa5ae52050524d8a9e0de714dd75c
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
.custom-label {
|
|
||||||
font-size: 20px;
|
|
||||||
-unity-font-style: bold;
|
|
||||||
color: rgb(68, 138, 255);
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<engine:UXML
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xmlns:engine="UnityEngine.UIElements"
|
|
||||||
xmlns:editor="UnityEditor.UIElements"
|
|
||||||
xsi:noNamespaceSchemaLocation="../../../UIElementsSchema/UIElements.xsd"
|
|
||||||
>
|
|
||||||
<Style src="project://database/Assets/UI%20Toolkit/EditorWindow/TestEditorWindow.uss?fileID=7433441132597879392&guid=e4abceb9650918a419c073e86d8fc3d6&type=3#TestEditorWindow" />
|
|
||||||
<engine:Label text="Hello World! From UXML" />
|
|
||||||
<engine:Label class="custom-label" text="Hello World! With Style" />
|
|
||||||
|
|
||||||
</engine:UXML>
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: d23b67a16b48c2243aabe57056dbfbed
|
|
||||||
ScriptedImporter:
|
|
||||||
internalIDToNameTable: []
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
|
|
||||||
<ui:Template name="Item" src="project://database/Assets/UI%20Toolkit/GamePanel/ShortcutMenu/ItemTemplate.uxml?fileID=9197481963319205126&guid=1ee167986f6e9a840a45450b4b6adfc2&type=3#ItemTemplate" />
|
|
||||||
<Style src="project://database/Assets/UI%20Toolkit/GamePanel/ShortcutMenu/ShortcutMenu.uss?fileID=7433441132597879392&guid=a53da9fc389948e40ac96af14dd02c10&type=3#ShortcutMenu" />
|
|
||||||
<ui:VisualElement name="Container" style="background-color: rgb(255, 255, 255); border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; align-self: flex-start;">
|
|
||||||
<ui:Instance template="Item" name="Item" />
|
|
||||||
<ui:Instance template="Item" name="Item" />
|
|
||||||
<ui:Instance template="Item" name="Item" />
|
|
||||||
<ui:Instance template="Item" name="Item" />
|
|
||||||
<ui:Instance template="Item" name="Item" />
|
|
||||||
</ui:VisualElement>
|
|
||||||
</ui:UXML>
|
|
||||||
@@ -9,7 +9,7 @@
|
|||||||
<ui:VisualElement class="toggle" style="flex-direction: row-reverse;">
|
<ui:VisualElement class="toggle" style="flex-direction: row-reverse;">
|
||||||
<ui:Label tabindex="-1" text="不在提示" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Title" class="toggle-title" style="color: rgb(28, 28, 28); padding-bottom: 5px; padding-top: 3px; padding-right: 3px; padding-left: 3px;" />
|
<ui:Label tabindex="-1" text="不在提示" parse-escape-sequences="true" display-tooltip-when-elided="true" name="Title" class="toggle-title" style="color: rgb(28, 28, 28); padding-bottom: 5px; padding-top: 3px; padding-right: 3px; padding-left: 3px;" />
|
||||||
<ui:VisualElement name="Input" class="toggle-input">
|
<ui:VisualElement name="Input" class="toggle-input">
|
||||||
<ui:VisualElement name="Check" class="toggle-check toggle-check-hide" style="background-image: url("project://database/Assets/UI%20Toolkit/DefaultTheme/UnityDefaultRuntimeTheme.tss?fileID=-6090568113533005507&guid=05f864e67ee1ecb4bbe67427564d394c&type=3#check"); -unity-background-image-tint-color: rgb(51, 51, 51);" />
|
<ui:VisualElement name="Check" class="toggle-check toggle-check-hide" style="background-image: url("project://database/Assets/UI%20Toolkit/UnityThemes/UnityDefaultRuntimeTheme.tss?fileID=-6090568113533005507&guid=05f864e67ee1ecb4bbe67427564d394c&type=3#check"); -unity-background-image-tint-color: rgb(51, 51, 51);" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: f59b127d657274c4e9b94a15b801c1a1
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
using UnityEditor.UIElements;
|
||||||
|
using MuHua;
|
||||||
|
|
||||||
|
namespace MuHuaEditor {
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑器
|
||||||
|
/// </summary>
|
||||||
|
public abstract class ModuleUIEditor<T> : Editor where T : Object {
|
||||||
|
/// <summary> UXML 资源 </summary>
|
||||||
|
public VisualTreeAsset VisualTreeAsset = default;
|
||||||
|
|
||||||
|
/// <summary> 选中目标 </summary>
|
||||||
|
protected T value;
|
||||||
|
/// <summary> 绑定文档 </summary>
|
||||||
|
public VisualElement Element = null;
|
||||||
|
/// <summary> 控件列表 </summary>
|
||||||
|
public List<UIControl> controls = new List<UIControl>();
|
||||||
|
|
||||||
|
public virtual void Awake() => value = target as T;
|
||||||
|
|
||||||
|
/// <summary> 在OnEnable中注册 </summary>
|
||||||
|
private void OnEnable() => EditorApplication.update += Update;
|
||||||
|
|
||||||
|
/// <summary> 在OnDisable中注销 </summary>
|
||||||
|
private void OnDisable() => EditorApplication.update -= Update;
|
||||||
|
|
||||||
|
public override VisualElement CreateInspectorGUI() {
|
||||||
|
VisualElement root = new VisualElement();
|
||||||
|
// 1. 添加 Script 字段(只读)
|
||||||
|
var scriptProperty = serializedObject.FindProperty("m_Script");
|
||||||
|
if (scriptProperty != null) {
|
||||||
|
var scriptField = new PropertyField(scriptProperty);
|
||||||
|
scriptField.SetEnabled(false); // 只读
|
||||||
|
root.Add(scriptField);
|
||||||
|
}
|
||||||
|
// 实例化 UXML
|
||||||
|
if (VisualTreeAsset != null) {
|
||||||
|
Element = VisualTreeAsset.Instantiate();
|
||||||
|
root.Add(Element);
|
||||||
|
Initial();
|
||||||
|
}
|
||||||
|
// 如果没设置 UXML,返回默认 Inspector
|
||||||
|
return root ?? new IMGUIContainer(() => DrawDefaultInspector());
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void Update() => controls.ForEach(control => control.Update());
|
||||||
|
|
||||||
|
public virtual void OnDestroy() => controls.ForEach(control => control.Dispose());
|
||||||
|
|
||||||
|
/// <summary> 初始化 </summary>
|
||||||
|
public abstract void Initial();
|
||||||
|
|
||||||
|
/// <summary> 添加控件 </summary>
|
||||||
|
public void AddControl(UIControl control) => controls.Add(control);
|
||||||
|
/// <summary> 移除控件 </summary>
|
||||||
|
public void RemoveControl(UIControl control) => controls.Remove(control);
|
||||||
|
/// <summary> 查询UI元素 </summary>
|
||||||
|
public VE Q<VE>(string name = null, string className = null) where VE : VisualElement => Element.Q<VE>(name, className);
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: d5f8ad3cc3aff1940bdf68f3d911a263
|
guid: a8a211ecbf2acb642a002e2ccac32de4
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
using MuHua;
|
||||||
|
|
||||||
|
namespace MuHuaEditor {
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑器窗口
|
||||||
|
/// </summary>
|
||||||
|
public abstract class ModuleUIEditorWindow : EditorWindow {
|
||||||
|
/// <summary> UXML 资源 </summary>
|
||||||
|
public VisualTreeAsset VisualTreeAsset = default;
|
||||||
|
|
||||||
|
/// <summary> 绑定文档 </summary>
|
||||||
|
public VisualElement Element;
|
||||||
|
/// <summary> 控件列表 </summary>
|
||||||
|
public List<UIControl> controls = new List<UIControl>();
|
||||||
|
|
||||||
|
public virtual void CreateGUI() {
|
||||||
|
// Instantiate UXML
|
||||||
|
Element = VisualTreeAsset.Instantiate();
|
||||||
|
Element.style.flexGrow = 1;
|
||||||
|
rootVisualElement.Add(Element);
|
||||||
|
Initial();
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void Update() => controls.ForEach(control => control.Update());
|
||||||
|
|
||||||
|
public virtual void OnDestroy() => controls.ForEach(control => control.Dispose());
|
||||||
|
|
||||||
|
/// <summary> 初始化 </summary>
|
||||||
|
public abstract void Initial();
|
||||||
|
|
||||||
|
/// <summary> 添加控件 </summary>
|
||||||
|
public void AddControl(UIControl control) => controls.Add(control);
|
||||||
|
/// <summary> 移除控件 </summary>
|
||||||
|
public void RemoveControl(UIControl control) => controls.Remove(control);
|
||||||
|
/// <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: 7a2fd8030b7392643995372e5c88631f
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"name": "ModuleEditor",
|
"name": "MuHuaEditor.UITool",
|
||||||
"rootNamespace": "",
|
"rootNamespace": "",
|
||||||
"references": [
|
"references": [
|
||||||
"GUID:432b70115e987f44abb984cfe7de384f"
|
"GUID:6206345d516a2bb4a821a7ee90e1b5d5"
|
||||||
],
|
],
|
||||||
"includePlatforms": [
|
"includePlatforms": [
|
||||||
"Editor"
|
"Editor"
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 779534da92936794a829f8bf18309372
|
guid: 3a65c91317a32ac438ed8542cf646c2f
|
||||||
AssemblyDefinitionImporter:
|
AssemblyDefinitionImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData:
|
||||||
@@ -71,9 +71,16 @@ namespace MuHua {
|
|||||||
}
|
}
|
||||||
/// <summary> 视图滚轮滑动 </summary>
|
/// <summary> 视图滚轮滑动 </summary>
|
||||||
private void ViewportWheel(WheelEvent evt) {
|
private void ViewportWheel(WheelEvent evt) {
|
||||||
float x = Mathf.Clamp(evt.delta.x, -1, 1);
|
float maxWidth = Viewport.resolvedStyle.width - Container.resolvedStyle.width;
|
||||||
float y = Mathf.Clamp(evt.delta.y, -1, 1);
|
float minWidth = Mathf.Min(Viewport.resolvedStyle.width, Container.resolvedStyle.width);
|
||||||
UpdateValue(new Vector2(value.x - x, value.y - y));
|
float x = evt.delta.x * minWidth / maxWidth;
|
||||||
|
|
||||||
|
float maxHeight = Viewport.resolvedStyle.height - Container.resolvedStyle.height;
|
||||||
|
float minHeight = Mathf.Min(Viewport.resolvedStyle.height, Container.resolvedStyle.height);
|
||||||
|
float y = evt.delta.y * minHeight / maxHeight;
|
||||||
|
|
||||||
|
value = value - new Vector2(x, y);
|
||||||
|
UpdateValue(value);
|
||||||
}
|
}
|
||||||
/// <summary> 拖拽按下 </summary>
|
/// <summary> 拖拽按下 </summary>
|
||||||
private void DraggerDown(PointerDownEvent evt) {
|
private void DraggerDown(PointerDownEvent evt) {
|
||||||
|
|||||||
@@ -76,8 +76,11 @@ namespace MuHua {
|
|||||||
}
|
}
|
||||||
/// <summary> 滚轮滑动 </summary>
|
/// <summary> 滚轮滑动 </summary>
|
||||||
private void ViewportWheel(WheelEvent evt) {
|
private void ViewportWheel(WheelEvent evt) {
|
||||||
float wheel = Mathf.Clamp(evt.delta.y, -1, 1);
|
float maxHeight = Viewport.resolvedStyle.height - Container.resolvedStyle.height;
|
||||||
UpdateValue(value - wheel);
|
float minHeight = Mathf.Min(Viewport.resolvedStyle.height, Container.resolvedStyle.height);
|
||||||
|
float y = evt.delta.y * minHeight / maxHeight;
|
||||||
|
value = value - y;
|
||||||
|
UpdateValue(value);
|
||||||
}
|
}
|
||||||
/// <summary> 拖拽按下 </summary>
|
/// <summary> 拖拽按下 </summary>
|
||||||
private void DraggerDown(PointerDownEvent evt) {
|
private void DraggerDown(PointerDownEvent evt) {
|
||||||
|
|||||||
@@ -76,8 +76,11 @@ namespace MuHua {
|
|||||||
}
|
}
|
||||||
/// <summary> 滚轮滑动 </summary>
|
/// <summary> 滚轮滑动 </summary>
|
||||||
private void ViewportWheel(WheelEvent evt) {
|
private void ViewportWheel(WheelEvent evt) {
|
||||||
float wheel = Mathf.Clamp(evt.delta.y, -1, 1);
|
float maxHeight = Viewport.resolvedStyle.height - Container.resolvedStyle.height;
|
||||||
UpdateValue(value - wheel);
|
float minHeight = Mathf.Min(Viewport.resolvedStyle.height, Container.resolvedStyle.height);
|
||||||
|
float y = evt.delta.y * minHeight / maxHeight;
|
||||||
|
value = value - y;
|
||||||
|
UpdateValue(value);
|
||||||
}
|
}
|
||||||
/// <summary> 拖拽按下 </summary>
|
/// <summary> 拖拽按下 </summary>
|
||||||
private void DraggerDown(PointerDownEvent evt) {
|
private void DraggerDown(PointerDownEvent evt) {
|
||||||
|
|||||||
Reference in New Issue
Block a user