s
This commit is contained in:
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
public class UIControlBaking : UnitUIControl {
|
||||
|
||||
#region UI元素
|
||||
public override VisualElement Element => ModuleUIPage.Q<VisualElement>("PlateBaking");
|
||||
public VisualElement Rendering => Element.Q<VisualElement>("Rendering");
|
||||
public Button Button1 => Element.Q<Button>("Button1");
|
||||
public Button Button2 => Element.Q<Button>("Button2");
|
||||
public Button Button3 => Element.Q<Button>("Button3");
|
||||
public Button Button4 => Element.Q<Button>("Button4");
|
||||
public Button Button5 => Element.Q<Button>("Button5");
|
||||
#endregion
|
||||
|
||||
#region 引用模块
|
||||
/// <summary> 视图相机模块 </summary>
|
||||
public ModuleViewCamera ViewCamera => ModuleCore.ViewCameraBaking;
|
||||
/// <summary> UI输入模块 </summary>
|
||||
public ModuleUIInput<UnitMouseInput> UIInput => ModuleCore.UIInputBaking;
|
||||
#endregion
|
||||
|
||||
public override void Awake() {
|
||||
Element.generateVisualContent += Element_GenerateVisualContent;
|
||||
Button1.clicked += () => { UIInput.ChangeInput(new BakingMobile()); };
|
||||
Button2.clicked += () => { UIInput.ChangeInput(new BakingMobilePlate()); };
|
||||
//Button3.clicked += () => { UIInput.ChangeInput(new DesignBezier()); };
|
||||
//Button4.clicked += () => { UIInputDesign.ChangeInput(new IDesignSelect()); };
|
||||
//Button5.clicked += () => { UIInputDesign.ChangeInput(new IDesignSelect()); };
|
||||
}
|
||||
private void Start() {
|
||||
UIInput.Binding(Rendering);
|
||||
UIInput.OnChangeInput += UIInputDesign_OnChangeInput;
|
||||
UIInput.ChangeInput(new BakingMobile());
|
||||
}
|
||||
|
||||
#region 更新视图
|
||||
private void Element_GenerateVisualContent(MeshGenerationContext context) {
|
||||
StartCoroutine(UpdateRenderTexture());
|
||||
}
|
||||
private IEnumerator UpdateRenderTexture() {
|
||||
yield return null;
|
||||
int width = (int)Element.resolvedStyle.width;
|
||||
int height = (int)Element.resolvedStyle.height;
|
||||
ViewCamera.UpdateRenderTexture(width, height);
|
||||
Background background = Background.FromRenderTexture(ViewCamera.RenderTexture);
|
||||
StyleBackground style = new StyleBackground(background);
|
||||
Rendering.style.backgroundImage = style;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 输入功能
|
||||
private void UIInputDesign_OnChangeInput(UnitMouseInput obj) {
|
||||
Type type = obj.GetType();
|
||||
ButtonStyleChange(type, typeof(BakingMobile), Button1);
|
||||
ButtonStyleChange(type, typeof(BakingMobilePlate), Button2);
|
||||
//ButtonStyleChange(type, typeof(DesignBezier), Button3);
|
||||
}
|
||||
private void ButtonStyleChange(Type obj, Type compare, Button button) {
|
||||
if (obj == compare) { button.AddToClassList("pb-button-s"); }
|
||||
else { button.RemoveFromClassList("pb-button-s"); }
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 64a73ef8100a7184c8668f3a50cb50d4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
public class UIControlDesign : UnitUIControl {
|
||||
|
||||
#region UI元素
|
||||
public override VisualElement Element => ModuleUIPage.Q<VisualElement>("PlateDesign");
|
||||
public VisualElement Rendering => Element.Q<VisualElement>("Rendering");
|
||||
public Button Button1 => Element.Q<Button>("Button1");
|
||||
public Button Button2 => Element.Q<Button>("Button2");
|
||||
public Button Button3 => Element.Q<Button>("Button3");
|
||||
public Button Button4 => Element.Q<Button>("Button4");
|
||||
public Button Button5 => Element.Q<Button>("Button5");
|
||||
public Button Button6 => Element.Q<Button>("Button6");
|
||||
public Button Button7 => Element.Q<Button>("Button7");
|
||||
#endregion
|
||||
|
||||
#region 引用模块
|
||||
/// <summary> 设计视图相机模块 </summary>
|
||||
public ModuleViewCamera ViewCamera => ModuleCore.ViewCameraDesign;
|
||||
/// <summary> 设计UI输入模块 </summary>
|
||||
public ModuleUIInput<UnitMouseInput> UIInputDesign => ModuleCore.UIInputDesign;
|
||||
#endregion
|
||||
|
||||
public override void Awake() {
|
||||
Element.generateVisualContent += Element_GenerateVisualContent;
|
||||
Button1.clicked += () => { UIInputDesign.ChangeInput(new DesignMobile()); };
|
||||
Button2.clicked += () => { UIInputDesign.ChangeInput(new DesignInsert()); };
|
||||
Button3.clicked += () => { UIInputDesign.ChangeInput(new DesignBezier()); };
|
||||
Button4.clicked += () => { UIInputDesign.ChangeInput(new DesignSuture()); };
|
||||
Button5.clicked += () => { UIInputDesign.ChangeInput(new DesignSutureReversal()); };
|
||||
}
|
||||
private void Start() {
|
||||
UIInputDesign.Binding(Rendering);
|
||||
UIInputDesign.OnChangeInput += UIInputDesign_OnChangeInput;
|
||||
UIInputDesign.ChangeInput(new DesignMobile());
|
||||
}
|
||||
private void OnDestroy() {
|
||||
if (UIInputDesign == null) { return; }
|
||||
UIInputDesign.OnChangeInput -= UIInputDesign_OnChangeInput;
|
||||
}
|
||||
|
||||
#region 更新视图
|
||||
private void Element_GenerateVisualContent(MeshGenerationContext context) {
|
||||
StartCoroutine(UpdateRenderTexture());
|
||||
}
|
||||
private IEnumerator UpdateRenderTexture() {
|
||||
yield return null;
|
||||
int width = (int)Element.resolvedStyle.width;
|
||||
int height = (int)Element.resolvedStyle.height;
|
||||
ViewCamera.UpdateRenderTexture(width, height);
|
||||
Background background = Background.FromRenderTexture(ViewCamera.RenderTexture);
|
||||
StyleBackground style = new StyleBackground(background);
|
||||
Rendering.style.backgroundImage = style;
|
||||
}
|
||||
#endregion
|
||||
|
||||
private void UIInputDesign_OnChangeInput(UnitMouseInput obj) {
|
||||
Type type = obj.GetType();
|
||||
ButtonStyleChange(type, typeof(DesignMobile), Button1);
|
||||
ButtonStyleChange(type, typeof(DesignInsert), Button2);
|
||||
ButtonStyleChange(type, typeof(DesignBezier), Button3);
|
||||
ButtonStyleChange(type, typeof(DesignSuture), Button4);
|
||||
ButtonStyleChange(type, typeof(DesignSutureReversal), Button5);
|
||||
}
|
||||
private void ButtonStyleChange(Type obj, Type compare, Button button) {
|
||||
if (obj == compare) { button.AddToClassList("pd-button-s"); }
|
||||
else { button.RemoveFromClassList("pd-button-s"); }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 141e3035b49c87441bdd757f6d978c1e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,63 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
public class UIControlInspect : UnitUIControl {
|
||||
|
||||
#region UI元素
|
||||
public override VisualElement Element => ModuleUIPage.Q<VisualElement>("Inspect");
|
||||
public VisualElement PlateSettings => Element.Q<VisualElement>("PlateSettings");
|
||||
public VisualElement PointSettings => Element.Q<VisualElement>("PointSettings");
|
||||
#endregion
|
||||
|
||||
#region 引用模块
|
||||
/// <summary> 广播查询数据模块 </summary>
|
||||
//public ModuleSending<DataFind> SendingFind => ModuleCore.SendingFind;
|
||||
#endregion
|
||||
|
||||
//private DataPlate Plate => SendingFind.Current.plate;
|
||||
//private DataPoint Point => SendingFind.Current.point;
|
||||
|
||||
private UIPlateSettings uiPlateSettings;
|
||||
private UIPointSettings uiPointSettings;
|
||||
public override void Awake() {
|
||||
uiPlateSettings = new UIPlateSettings(PlateSettings);
|
||||
|
||||
uiPointSettings = new UIPointSettings(PointSettings);
|
||||
//uiPointSettings.Toggle1.OnChange += (value) => { Point.isCurveFront = value; Plate.UpdateVisual(); };
|
||||
//uiPointSettings.Toggle2.OnChange += (value) => { Point.isCurveAfter = value; Plate.UpdateVisual(); };
|
||||
}
|
||||
|
||||
private void Start() {
|
||||
//SendingFind.OnChange += SendingFind_OnChange;
|
||||
}
|
||||
|
||||
//private void SendingFind_OnChange(DataFind obj) {
|
||||
// PointSettings.style.display = DisplayStyle.None;
|
||||
// PlateSettings.style.display = DisplayStyle.None;
|
||||
// if (obj.IsValidPoint) { UpdateUIPointSettings(); return; }
|
||||
// if (obj.IsValidPlate) { UpdateUIPlateSettings(); return; }
|
||||
//}
|
||||
private void UpdateUIPlateSettings() {
|
||||
PlateSettings.style.display = DisplayStyle.Flex;
|
||||
}
|
||||
private void UpdateUIPointSettings() {
|
||||
PointSettings.style.display = DisplayStyle.Flex;
|
||||
//uiPointSettings.Toggle1.SetValue(Point.isCurveFront);
|
||||
//uiPointSettings.Toggle2.SetValue(Point.isCurveAfter);
|
||||
}
|
||||
|
||||
public class UIPlateSettings {
|
||||
public readonly VisualElement element;
|
||||
public UIPlateSettings(VisualElement element) => this.element = element;
|
||||
}
|
||||
public class UIPointSettings {
|
||||
public readonly VisualElement element;
|
||||
public VisualElement Bezier => element.Q<VisualElement>("Bezier");
|
||||
public MUToggle Toggle1 => element.Q<MUToggle>("Toggle1");
|
||||
public MUToggle Toggle2 => element.Q<MUToggle>("Toggle2");
|
||||
public UIPointSettings(VisualElement element) => this.element = element;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e19ef8edf7b1d7844838898350516ef8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
public abstract class UnitUIControl : MonoBehaviour {
|
||||
/// <summary> 绑定的页面 </summary>
|
||||
public ModuleUIPage ModuleUIPage;
|
||||
/// <summary> 必须初始化 </summary>
|
||||
public abstract void Awake();
|
||||
/// <summary> 核心模块 </summary>
|
||||
protected virtual ModuleCore ModuleCore => ModuleCore.I;
|
||||
|
||||
public abstract VisualElement Element { get; }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 78a3f28d3b5c8334f8dcfa20b5e73d29
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user