1
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// UI模块
|
||||
/// </summary>
|
||||
public class ModuleUI : ModuleUISingle<ModuleUI> {
|
||||
/// <summary> 当前页面 </summary>
|
||||
public static Page Current;
|
||||
/// <summary> 回退页面 </summary>
|
||||
public static Page BackPage;
|
||||
/// <summary> 控件列表 </summary>
|
||||
public static List<UIControl> controls = new List<UIControl>();
|
||||
/// <summary> 页面跳转事件 </summary>
|
||||
public static event Action<Page> OnJumpPage;
|
||||
|
||||
/// <summary> 跳转页面 </summary>
|
||||
public static void Settings(Page pageType) {
|
||||
BackPage = Current;
|
||||
Current = pageType;
|
||||
OnJumpPage?.Invoke(Current);
|
||||
}
|
||||
/// <summary> 回退页面 </summary>
|
||||
public static void Back() {
|
||||
Current = BackPage;
|
||||
OnJumpPage?.Invoke(Current);
|
||||
}
|
||||
/// <summary> 添加控件 </summary>
|
||||
public static void AddControl(UIControl control) {
|
||||
controls.Add(control);
|
||||
}
|
||||
/// <summary> 移除控件 </summary>
|
||||
public static void RemoveControl(UIControl control) {
|
||||
controls.Remove(control);
|
||||
}
|
||||
|
||||
public override VisualElement Element => document.rootVisualElement;
|
||||
|
||||
protected override void Awake() => NoReplace();
|
||||
|
||||
private void Update() => controls.ForEach(control => control.Update());
|
||||
|
||||
private void OnDestroy() => controls.ForEach(control => control.Dispose());
|
||||
}
|
||||
/// <summary>
|
||||
/// 页面
|
||||
/// </summary>
|
||||
public enum Page {
|
||||
/// <summary> 无 </summary>
|
||||
None,
|
||||
/// <summary> 登录 </summary>
|
||||
Login,
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea89ac05041b5d74582ee9d0add233ac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b8f196d318cab0f47a3c84eade044392
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b6be8605ab2df3348bdd03749d5ca2c5
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06f31db1c09e8a0409a8b3b960a13216
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,48 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d5f8ad3cc3aff1940bdf68f3d911a263
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,64 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0898288ac15d9a4e9a82e0d6d36ff17
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,63 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 36d613e41a27e8f40be6e6c05de1aeb1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,113 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 00c04ca4ef821d0469a77408648f5ff2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a20e449063139b4ea0d19bd0677c7d1
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5003b2a36519747449a4b6e4d7e5f56e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0d9cdd61f07fb14a93de29e68c71787
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,31 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d21953f5fb6c41e40b2df711d80a42b3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,31 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 496a1fe1e90187b45b931ec732c0bde6
|
||||
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;
|
||||
|
||||
public class UIBannerTip : 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: 7279e9c7234eb6645b7b1e172b70919d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,132 @@
|
||||
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; });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8df138b434ab51f40b134f831376120e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,31 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 637e7bc032a4bee4aa936fb481495299
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fcb666edf8774b643830fdbb6a3973bd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,31 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2da9aad7a772f434080f14bd479de19c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,17 @@
|
||||
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);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 58ce28d05656cfd498fc2555599e349c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user