代码合并

This commit is contained in:
MuHua-123
2024-11-08 18:15:06 +08:00
parent 5f169b90bb
commit 497b43a446
146 changed files with 2858 additions and 110 deletions
@@ -0,0 +1,17 @@
.pd-button {
height: 30px;
background-color: rgb(204, 204, 204);
border-top-left-radius: 0;
border-top-right-radius: 0;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
margin-top: 2px;
border-top-width: 0;
border-right-width: 0;
border-bottom-width: 0;
border-left-width: 0;
}
.pd-button-s {
background-color: rgb(0, 235, 255);
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 61655961f50792845ab24ff6cded58d9
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
disableValidation: 0
@@ -0,0 +1,13 @@
<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/UIComponent/PlateDesign/PlateDesign.uss?fileID=7433441132597879392&amp;guid=61655961f50792845ab24ff6cded58d9&amp;type=3#PlateDesign" />
<ui:VisualElement style="flex-grow: 1; width: 100%; height: 100%; overflow: hidden;">
<ui:VisualElement name="Rendering" style="flex-grow: 1;" />
<ui:VisualElement style="position: absolute; height: 162px; width: 40px; left: 10px; top: 10px; background-color: rgb(51, 51, 51); border-top-left-radius: 5px; border-top-right-radius: 5px; border-bottom-right-radius: 5px; border-bottom-left-radius: 5px; padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px;">
<ui:Button parse-escape-sequences="true" display-tooltip-when-elided="true" name="Button1" class="pd-button" style="margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; border-top-left-radius: 4px; border-top-right-radius: 4px; border-left-color: rgba(0, 0, 0, 0); border-right-color: rgba(0, 0, 0, 0); border-top-color: rgba(0, 0, 0, 0); border-bottom-color: rgba(0, 0, 0, 0);" />
<ui:Button parse-escape-sequences="true" display-tooltip-when-elided="true" name="Button2" class="pd-button" style="padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; border-top-left-radius: 0; border-top-right-radius: 0; border-left-color: rgba(0, 0, 0, 0); border-right-color: rgba(0, 0, 0, 0); border-top-color: rgba(0, 0, 0, 0); border-bottom-color: rgba(0, 0, 0, 0); margin-top: 2px; margin-right: 0; margin-bottom: 0; margin-left: 0; border-bottom-right-radius: 0; border-bottom-left-radius: 0;" />
<ui:Button parse-escape-sequences="true" display-tooltip-when-elided="true" name="Button3" class="pd-button" style="padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; border-top-left-radius: 0; border-top-right-radius: 0; border-left-color: rgba(0, 0, 0, 0); border-right-color: rgba(0, 0, 0, 0); border-top-color: rgba(0, 0, 0, 0); border-bottom-color: rgba(0, 0, 0, 0); margin-top: 2px; margin-right: 0; margin-bottom: 0; margin-left: 0; border-bottom-right-radius: 0; border-bottom-left-radius: 0;" />
<ui:Button parse-escape-sequences="true" display-tooltip-when-elided="true" name="Button4" class="pd-button" style="padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; border-top-left-radius: 0; border-top-right-radius: 0; border-left-color: rgba(0, 0, 0, 0); border-right-color: rgba(0, 0, 0, 0); border-top-color: rgba(0, 0, 0, 0); border-bottom-color: rgba(0, 0, 0, 0); margin-top: 2px; margin-right: 0; margin-bottom: 0; margin-left: 0; border-bottom-right-radius: 0; border-bottom-left-radius: 0;" />
<ui:Button parse-escape-sequences="true" display-tooltip-when-elided="true" name="Button5" class="pd-button" style="padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0; border-top-left-radius: 0; border-top-right-radius: 0; border-left-color: rgba(0, 0, 0, 0); border-right-color: rgba(0, 0, 0, 0); border-top-color: rgba(0, 0, 0, 0); border-bottom-color: rgba(0, 0, 0, 0); margin-top: 2px; margin-right: 0; margin-bottom: 0; margin-left: 0; border-bottom-right-radius: 4px; border-bottom-left-radius: 4px;" />
</ui:VisualElement>
</ui:VisualElement>
</ui:UXML>
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: ba059349af6076b40b0e35856489786c
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
@@ -0,0 +1,96 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UIElements;
public class UIPlateDesign {
public readonly VisualElement element;
public ModuleViewInput viewInput => ModuleCore.I.PlateDesignViewInput;
public ModuleViewCamera viewCamera => ModuleCore.I.PlateDesignViewCamera;
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 UIPlateDesign(VisualElement element) {
this.element = element;
viewInput.OnInputType += ViewInput_OnInputType;
element.generateVisualContent += Element_GenerateVisualContent;
Rendering.RegisterCallback<MouseDownEvent>(DownMouse);
Rendering.RegisterCallback<MouseMoveEvent>(DragMouse);
Rendering.RegisterCallback<MouseUpEvent>(ReleaseMouse);
Rendering.RegisterCallback<MouseOutEvent>(ReleaseMouse);
Rendering.RegisterCallback<WheelEvent>(ScrollWheel);
//边缘点操作
//Button1.clicked += () => { viewInput.SetPrimaryKeyInput(new VIUEdgePointMobile(viewCamera)); };
//Button2.clicked += () => { viewInput.SetPrimaryKeyInput(new VIUEdgePointAdd(viewCamera)); };
//设计点操作
Button1.clicked += () => { viewInput.SetPrimaryKeyInput(new VIUDesignPointMobile(viewCamera)); };
Button2.clicked += () => { viewInput.SetPrimaryKeyInput(new VIUDesignPointInsert(viewCamera)); };
Button3.clicked += () => { viewInput.SetPrimaryKeyInput(new VIUBezierMobile(viewCamera)); };
viewInput.SetPrimaryKeyInput(new VIUDesignPointMobile(viewCamera));
}
private void ViewInput_OnInputType(Type obj) {
//边缘点操作
//ChangeStyle(obj, typeof(VIUEdgePointMobile), Button1);
//ChangeStyle(obj, typeof(VIUEdgePointAdd), Button2);
//设计点操作
ChangeStyle(obj, typeof(VIUDesignPointMobile), Button1);
ChangeStyle(obj, typeof(VIUDesignPointInsert), Button2);
ChangeStyle(obj, typeof(VIUBezierMobile), Button3);
}
private void ChangeStyle(Type obj, Type compare, VisualElement visualElement) {
if (obj == compare) { visualElement.AddToClassList("pd-button-s"); }
else { visualElement.RemoveFromClassList("pd-button-s"); }
}
private void Element_GenerateVisualContent(MeshGenerationContext context) {
ModuleCore.I.ModuleAgent.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;
}
private bool isDownLeftMouse;
private bool isDownRightMouse;
private bool isDownMiddleMouse;
public void DownMouse(MouseDownEvent evt) {
DataMouseInput mouseInput = new DataMouseInput(evt);
if (evt.button == 0) { viewInput.DownLeftMouse(mouseInput); isDownLeftMouse = true; }
if (evt.button == 1) { viewInput.DownRightMouse(mouseInput); isDownRightMouse = true; }
if (evt.button == 2) { viewInput.DownMiddleMouse(mouseInput); isDownMiddleMouse = true; }
}
public void DragMouse(MouseMoveEvent evt) {
DataMouseInput mouseInput = new DataMouseInput(evt);
if (isDownLeftMouse) { viewInput.DragLeftMouse(mouseInput); }
if (isDownRightMouse) { viewInput.DragRightMouse(mouseInput); }
if (isDownMiddleMouse) { viewInput.DragMiddleMouse(mouseInput); }
if (evt.button == 0) { viewInput.MoveLeftMouse(mouseInput); }
if (evt.button == 1) { viewInput.MoveRightMouse(mouseInput); }
if (evt.button == 2) { viewInput.MoveMiddleMouse(mouseInput); }
}
public void ReleaseMouse(MouseUpEvent evt) {
DataMouseInput mouseInput = new DataMouseInput(evt);
viewInput.ReleaseLeftMouse(mouseInput); isDownLeftMouse = false;
viewInput.ReleaseRightMouse(mouseInput); isDownRightMouse = false;
viewInput.ReleaseMiddleMouse(mouseInput); isDownMiddleMouse = false;
}
public void ReleaseMouse(MouseOutEvent evt) {
DataMouseInput mouseInput = new DataMouseInput(evt);
viewInput.ReleaseLeftMouse(mouseInput); isDownLeftMouse = false;
viewInput.ReleaseRightMouse(mouseInput); isDownRightMouse = false;
viewInput.ReleaseMiddleMouse(mouseInput); isDownMiddleMouse = false;
}
public void ScrollWheel(WheelEvent evt) {
DataMouseInput mouseInput = new DataMouseInput(evt);
viewInput.ScrollWheel(mouseInput);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c0ce22839c16abf4e8397a948f702523
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: