代码合并
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e350a719b66eb849983fdce5dcb2025
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f5ae9284505c4b940b508a7f812159eb
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,31 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class VIUBezierMobile : ModuleViewInputUnit {
|
||||
private Vector3 mousePosition;
|
||||
private Vector3 originalPosition;
|
||||
private readonly ModuleViewCamera viewCamera;
|
||||
private ModulePlateDesign PlateDesign => ModuleCore.I.PlateDesign;
|
||||
public VIUBezierMobile(ModuleViewCamera viewCamera) {
|
||||
this.viewCamera = viewCamera;
|
||||
}
|
||||
public override void DownMouse(DataMouseInput data) {
|
||||
PlateDesign.SelectBezierPoint(data.ScreenPosition);
|
||||
if (!PlateDesign.IsValidBezierPoint) { return; }
|
||||
mousePosition = viewCamera.ScreenToWorldPosition(data.ScreenPosition);
|
||||
originalPosition = PlateDesign.BezierPointPosition;
|
||||
}
|
||||
public override void DragMouse(DataMouseInput data) {
|
||||
if (!PlateDesign.IsValidBezierPoint) { return; }
|
||||
Vector3 current = viewCamera.ScreenToWorldPosition(data.ScreenPosition);
|
||||
Vector3 offset = current - mousePosition;
|
||||
PlateDesign.ChangeBezierPoint(originalPosition + offset);
|
||||
}
|
||||
public override void ReleaseMouse(DataMouseInput data) {
|
||||
PlateDesign.ReleaseBezierPoint();
|
||||
}
|
||||
public override void ScrollWheel(DataMouseInput data) {
|
||||
PlateDesign.ReleaseBezierPoint();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a819c02b79cf50242803b88efbb134c1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,27 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class VIUCameraMobile : ModuleViewInputUnit {
|
||||
private Vector3 mousePosition;
|
||||
private Vector3 originalPosition;
|
||||
private readonly ModuleViewCamera viewCamera;
|
||||
public VIUCameraMobile(ModuleViewCamera viewCamera) {
|
||||
this.viewCamera = viewCamera;
|
||||
}
|
||||
public override void DownMouse(DataMouseInput data) {
|
||||
mousePosition = viewCamera.ScreenToWorldPosition(data.ScreenPosition);
|
||||
originalPosition = viewCamera.Position;
|
||||
}
|
||||
public override void DragMouse(DataMouseInput data) {
|
||||
Vector3 current = viewCamera.ScreenToWorldPosition(data.ScreenPosition);
|
||||
Vector3 offset = current - mousePosition;
|
||||
viewCamera.Position = originalPosition + offset;
|
||||
}
|
||||
public override void ReleaseMouse(DataMouseInput data) {
|
||||
|
||||
}
|
||||
public override void ScrollWheel(DataMouseInput data) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ba32fb2f11bf1948bdaae8823a824b2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class VIUCameraRotate : ModuleViewInputUnit {
|
||||
private float mouseRotate;
|
||||
private float originalRotate;
|
||||
private readonly ModuleViewCamera viewCamera;
|
||||
public VIUCameraRotate(ModuleViewCamera viewCamera) {
|
||||
this.viewCamera = viewCamera;
|
||||
}
|
||||
public override void DownMouse(DataMouseInput data) {
|
||||
mouseRotate = viewCamera.ScreenToViewPosition(data.ScreenPosition).x;
|
||||
originalRotate = viewCamera.EulerAngles.y;
|
||||
}
|
||||
public override void DragMouse(DataMouseInput data) {
|
||||
float current = viewCamera.ScreenToViewPosition(data.ScreenPosition).x;
|
||||
float offset = (current - mouseRotate) * 360;
|
||||
viewCamera.EulerAngles = new Vector3(0, originalRotate - offset, 0);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 535c46cee34ae5e49802e537ad5a7a13
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class VIUCameraScale : ModuleViewInputUnit {
|
||||
public enum ScaleType { Scale, Orthographic }
|
||||
private readonly ScaleType scaleType;
|
||||
private readonly ModuleViewCamera viewCamera;
|
||||
public VIUCameraScale(ModuleViewCamera viewCamera, ScaleType scaleType = ScaleType.Scale) {
|
||||
this.viewCamera = viewCamera;
|
||||
this.scaleType = scaleType;
|
||||
}
|
||||
public override void DownMouse(DataMouseInput data) {
|
||||
|
||||
}
|
||||
public override void DragMouse(DataMouseInput data) {
|
||||
|
||||
}
|
||||
public override void ReleaseMouse(DataMouseInput data) {
|
||||
|
||||
}
|
||||
public override void ScrollWheel(DataMouseInput data) {
|
||||
if (scaleType == ScaleType.Scale) {
|
||||
float size = viewCamera.LocalScale.x + data.ScrollWheel;
|
||||
size = Mathf.Clamp(size, 0.5f, 4);
|
||||
Vector3 localScale = new Vector3(size, size, size);
|
||||
viewCamera.LocalScale = Vector3.Lerp(viewCamera.LocalScale, localScale, Time.deltaTime * 20);
|
||||
}
|
||||
if (scaleType == ScaleType.Orthographic) {
|
||||
float size = viewCamera.OrthographicSize + data.ScrollWheel;
|
||||
size = Mathf.Clamp(size, 0.1f, 4);
|
||||
viewCamera.OrthographicSize = Mathf.Lerp(viewCamera.OrthographicSize, size, Time.deltaTime * 20);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e00fcc9528ea97040bcdee04b0279778
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class VIUDesignPointInsert : ModuleViewInputUnit {
|
||||
private readonly ModuleViewCamera viewCamera;
|
||||
private ModulePlateDesign PlateDesign => ModuleCore.I.PlateDesign;
|
||||
public VIUDesignPointInsert(ModuleViewCamera viewCamera) {
|
||||
this.viewCamera = viewCamera;
|
||||
}
|
||||
public override void DownMouse(DataMouseInput data) {
|
||||
PlateDesign.InsertDesignPoint(data.ScreenPosition);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8b8b6a3b0a7e1e649bdcd0615dfa80ed
|
||||
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;
|
||||
|
||||
public class VIUDesignPointMobile : ModuleViewInputUnit {
|
||||
private Vector3 mousePosition;
|
||||
private Vector3 originalPosition;
|
||||
private readonly ModuleViewCamera viewCamera;
|
||||
private ModulePlateDesign PlateDesign => ModuleCore.I.PlateDesign;
|
||||
public VIUDesignPointMobile(ModuleViewCamera viewCamera) {
|
||||
this.viewCamera = viewCamera;
|
||||
}
|
||||
public override void DownMouse(DataMouseInput data) {
|
||||
PlateDesign.SelectDesignPoint(data.ScreenPosition);
|
||||
if (!PlateDesign.IsValidDesignPoint) { return; }
|
||||
mousePosition = viewCamera.ScreenToWorldPosition(data.ScreenPosition);
|
||||
originalPosition = PlateDesign.DesignPointPosition;
|
||||
}
|
||||
public override void DragMouse(DataMouseInput data) {
|
||||
if (!PlateDesign.IsValidDesignPoint) { return; }
|
||||
Vector3 current = viewCamera.ScreenToWorldPosition(data.ScreenPosition);
|
||||
Vector3 offset = current - mousePosition;
|
||||
PlateDesign.ChangeDesignPoint(originalPosition + offset);
|
||||
}
|
||||
public override void ReleaseMouse(DataMouseInput data) {
|
||||
PlateDesign.ReleaseDesignPoint();
|
||||
}
|
||||
public override void ScrollWheel(DataMouseInput data) {
|
||||
PlateDesign.ReleaseDesignPoint();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb31bfbd0ef82f24b823836852bd846c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class VIUEdgePointAdd : ModuleViewInputUnit {
|
||||
private readonly ModuleViewCamera viewCamera;
|
||||
private ModulePlateDesign PlateDesign => ModuleCore.I.PlateDesign;
|
||||
public VIUEdgePointAdd(ModuleViewCamera viewCamera) {
|
||||
this.viewCamera = viewCamera;
|
||||
}
|
||||
public override void DownMouse(DataMouseInput data) {
|
||||
PlateDesign.InsertEdgePoint(data.ScreenPosition);
|
||||
}
|
||||
public override void MoveMouse(DataMouseInput data) {
|
||||
//Vector3 position = viewCamera.ScreenToWorldPosition(data.ScreenPosition);
|
||||
//Vector3 worldPosition = position + viewCamera.CameraWorldPosition;
|
||||
//worldPosition.z = 0;
|
||||
//Collider2D[] colliders = Physics2D.OverlapCircleAll(worldPosition, range, DefaultLayerMask);
|
||||
//if (colliders.Length == 0) { return; }
|
||||
//edgePoint = colliders[0].GetComponentInParent<PrefabEdgePoint>();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c0e8f369912dbb4e9d906ca3d14a628
|
||||
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;
|
||||
|
||||
public class VIUEdgePointMobile : ModuleViewInputUnit {
|
||||
private Vector3 mousePosition;
|
||||
private Vector3 originalPosition;
|
||||
private readonly ModuleViewCamera viewCamera;
|
||||
private ModulePlateDesign PlateDesign => ModuleCore.I.PlateDesign;
|
||||
public VIUEdgePointMobile(ModuleViewCamera viewCamera) {
|
||||
this.viewCamera = viewCamera;
|
||||
}
|
||||
public override void DownMouse(DataMouseInput data) {
|
||||
PlateDesign.SelectEdgePoint(data.ScreenPosition);
|
||||
if (!PlateDesign.IsValidEdgePoint) { return; }
|
||||
mousePosition = viewCamera.ScreenToWorldPosition(data.ScreenPosition);
|
||||
originalPosition = PlateDesign.EdgePointPosition;
|
||||
}
|
||||
public override void DragMouse(DataMouseInput data) {
|
||||
if (!PlateDesign.IsValidEdgePoint) { return; }
|
||||
Vector3 current = viewCamera.ScreenToWorldPosition(data.ScreenPosition);
|
||||
Vector3 offset = current - mousePosition;
|
||||
PlateDesign.ChangeEdgePoint(originalPosition + offset);
|
||||
}
|
||||
public override void ReleaseMouse(DataMouseInput data) {
|
||||
PlateDesign.ReleaseEdgePoint();
|
||||
}
|
||||
public override void ScrollWheel(DataMouseInput data) {
|
||||
PlateDesign.ReleaseEdgePoint();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ae2a8f6a151f160479bd605f2c407a8d
|
||||
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 abstract class ModuleViewInputUnit {
|
||||
/// <summary> 核心模块 </summary>
|
||||
protected virtual ModuleCore ModuleCore => ModuleCore.I;
|
||||
/// <summary> 按下鼠标左键 </summary>
|
||||
public virtual void DownMouse(DataMouseInput data) { }
|
||||
/// <summary> 拖拽鼠标左键 </summary>
|
||||
public virtual void DragMouse(DataMouseInput data) { }
|
||||
/// <summary> 释放鼠标左键 </summary>
|
||||
public virtual void ReleaseMouse(DataMouseInput data) { }
|
||||
/// <summary> 移动鼠标 </summary>
|
||||
public virtual void MoveMouse(DataMouseInput data) { }
|
||||
/// <summary> 鼠标滚轮 </summary>
|
||||
public virtual void ScrollWheel(DataMouseInput data) { }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 15cfd3c63263fc14fbb47c12c18447ff
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,10 +1,9 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary> 代理模块 </summary>
|
||||
public abstract class ModuleAgent : MonoBehaviour {
|
||||
public abstract void AgentNetwork(DataNetwork data);
|
||||
public abstract void AgentLoadingNetwork(DataNetwork data);
|
||||
protected abstract void Awake();
|
||||
|
||||
protected virtual ModuleCore ModuleCore => ModuleCore.I;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84e24d973daa9564db536bd009ec11cc
|
||||
guid: 7922d1530e2c0f94f9ef1bdff77aa89b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class ModuleAlgorithm<Data> {
|
||||
/// <summary> 核心模块 </summary>
|
||||
protected virtual ModuleCore ModuleCore => ModuleCore.I;
|
||||
/// <summary> 执行算法 </summary>
|
||||
public abstract void Compute(Data data);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 080083324a409f24788f08ea7c670304
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class ModuleAssets<Data> : MonoBehaviour {
|
||||
[SerializeField] protected List<Data> assets;
|
||||
/// <summary> 资产列表 </summary>
|
||||
public virtual List<Data> Assets => assets;
|
||||
/// <summary> 必须要初始化 </summary>
|
||||
protected abstract void Awake();
|
||||
/// <summary> 核心模块 </summary>
|
||||
protected virtual ModuleCore ModuleCore => ModuleCore.I;
|
||||
/// <summary> 循环列表 </summary>
|
||||
public abstract void ForEach(Action<Data> action);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 424b00686a91cd64989e546f204155a5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -4,36 +4,43 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MuHua;
|
||||
|
||||
/// <summary>
|
||||
/// 核心模块,提供全部的抽象接口
|
||||
/// </summary>
|
||||
public class ModuleCore : Module<ModuleCore> {
|
||||
/*---------------------------------------------功能模块--------------------------------------------------------*/
|
||||
/// <summary> 视频模块 </summary>
|
||||
public ModuleVideo ModuleVideo;
|
||||
/// <summary> 场景模块 </summary>
|
||||
public ModuleScene ModuleScene;
|
||||
/// <summary> 代理模块 </summary>
|
||||
public ModuleAgent ModuleAgent;
|
||||
/*---------------------------------------------页面模块--------------------------------------------------------*/
|
||||
/// <summary> 当前的主要页面模块 (UIDocument) </summary>
|
||||
public ModuleUIPage CurrentPage;
|
||||
|
||||
#region 资产模块
|
||||
/// <summary> 预设模板资产 </summary>
|
||||
public ModuleAssets<DataPresetsPlate> PresetsPlateAssets;
|
||||
#endregion
|
||||
|
||||
#region 页面模块
|
||||
/// <summary> 不会被销毁的全局唯一页面模块 (UIDocument) </summary>
|
||||
public ModuleUIPage GlobalPage;
|
||||
/*---------------------------------------------页面模块--------------------------------------------------------*/
|
||||
/// <summary> 加载页面模块 (回调Action) </summary>
|
||||
public ModuleUIPanel<Action> LoadingPanel;
|
||||
/// <summary> 弹出提示模块 </summary>
|
||||
public ModuleUIPanel<string> PopupPromptPanel;
|
||||
/// <summary> 弹出窗口模块 </summary>
|
||||
public ModuleUIPanel<DataPopup> PopupWindowPanel;
|
||||
/// <summary> 当前的主要页面模块 (UIDocument) </summary>
|
||||
public ModuleUIPage CurrentPage;
|
||||
/// <summary> 预设模板窗口 (回调Action) </summary>
|
||||
public ModuleUIWindow<Action> PresetsPlateWindow;
|
||||
#endregion
|
||||
|
||||
/// <summary> 设备视频交互模块 </summary>
|
||||
public ModuleUIPanel<DataVideo> VideoPanel;
|
||||
/// <summary> 设备视频图文交互模块 </summary>
|
||||
public ModuleUIPanel<DataVideoImage> VideoImagePanel;
|
||||
/// <summary> 学习视频模块 (回调Action) </summary>
|
||||
public ModuleUIPanel<Action> LearningVideoPanel;
|
||||
/// <summary> 全屏播放视频模块 (回调Action) </summary>
|
||||
public ModuleUIPanel<Action> FullScreenVideoPanel;
|
||||
#region 功能模块
|
||||
/// <summary> 代理模块 </summary>
|
||||
public ModuleAgent ModuleAgent;
|
||||
/// <summary> 根据设计点生成边缘算法模块 </summary>
|
||||
public ModuleAlgorithm<DataPlate> GenerateEdge = new AlgorithmGenerateEdge();
|
||||
/// <summary> 边缘排序算法模块 </summary>
|
||||
public ModuleAlgorithm<DataPlate> EdgeSort = new AlgorithmEdge();
|
||||
/// <summary> 多边形算法模块 </summary>
|
||||
public ModuleAlgorithm<DataPlate> Polygon = new AlgorithmPolygon();
|
||||
/// <summary> 板片设计模块 </summary>
|
||||
public ModulePlateDesign PlateDesign;
|
||||
/// <summary> 板片设计相机视图 </summary>
|
||||
public ModuleViewCamera PlateDesignViewCamera;
|
||||
/// <summary> 板片烘焙相机视图 </summary>
|
||||
public ModuleViewCamera PlateBakingViewCamera;
|
||||
#endregion
|
||||
|
||||
#region 控制模块
|
||||
/// <summary> 板片设计输入模块 </summary>
|
||||
public ModuleViewInput PlateDesignViewInput;
|
||||
/// <summary> 板片烘焙输入模块 </summary>
|
||||
public ModuleViewInput PlateBakingViewInput;
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 98eb035eb7e5cc14694ed78d4215f579
|
||||
guid: 8b523f207d584d649bb29f4a06b5428d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class ModulePlateDesign : MonoBehaviour {
|
||||
/// <summary> 必须初始化 </summary>
|
||||
protected virtual void Awake() {
|
||||
ModuleCore.PlateDesign = this;
|
||||
}
|
||||
/// <summary> 核心模块 </summary>
|
||||
protected virtual ModuleCore ModuleCore => ModuleCore.I;
|
||||
/// <summary> 视图相机模块 </summary>
|
||||
protected virtual ModuleViewCamera ViewCamera => ModuleCore.PlateDesignViewCamera;
|
||||
|
||||
/// <summary> 添加一个板片数据 </summary>
|
||||
public abstract void AddData(DataPlate data);
|
||||
|
||||
#region 边缘点操作
|
||||
/// <summary> 是否有效的边缘点 </summary>
|
||||
public abstract bool IsValidEdgePoint { get; }
|
||||
/// <summary> 返回当前边缘点位置 </summary>
|
||||
public abstract Vector3 EdgePointPosition { get; }
|
||||
/// <summary> 选中一个边缘点 </summary>
|
||||
public abstract void SelectEdgePoint(Vector3 screenPosition);
|
||||
/// <summary> 改变边缘点位置 </summary>
|
||||
public abstract void ChangeEdgePoint(Vector3 localPosition);
|
||||
/// <summary> 插入一个边缘点 </summary>
|
||||
public abstract void InsertEdgePoint(Vector3 screenPosition);
|
||||
/// <summary> 释放边缘点 </summary>
|
||||
public abstract void ReleaseEdgePoint();
|
||||
#endregion
|
||||
|
||||
#region 设计点操作
|
||||
/// <summary> 是否有效的设计点 </summary>
|
||||
public abstract bool IsValidDesignPoint { get; }
|
||||
/// <summary> 返回当前设计点位置 </summary>
|
||||
public abstract Vector3 DesignPointPosition { get; }
|
||||
/// <summary> 选中一个设计点 </summary>
|
||||
public abstract void SelectDesignPoint(Vector3 screenPosition);
|
||||
/// <summary> 改变设计点位置 </summary>
|
||||
public abstract void ChangeDesignPoint(Vector3 localPosition);
|
||||
/// <summary> 插入一个设计点 </summary>
|
||||
public abstract void InsertDesignPoint(Vector3 screenPosition);
|
||||
/// <summary> 释放设计点 </summary>
|
||||
public abstract void ReleaseDesignPoint();
|
||||
#endregion
|
||||
|
||||
#region 贝塞尔曲线操作
|
||||
/// <summary> 是否有效的贝塞尔点 </summary>
|
||||
public abstract bool IsValidBezierPoint { get; }
|
||||
/// <summary> 返回当前贝塞尔点位置 </summary>
|
||||
public abstract Vector3 BezierPointPosition { get; }
|
||||
/// <summary> 选中一个贝塞尔点 </summary>
|
||||
public abstract void SelectBezierPoint(Vector3 screenPosition);
|
||||
/// <summary> 改变贝塞尔点位置 </summary>
|
||||
public abstract void ChangeBezierPoint(Vector3 localPosition);
|
||||
/// <summary> 释放贝塞尔点 </summary>
|
||||
public abstract void ReleaseBezierPoint();
|
||||
#endregion
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c5b9eb7c85f467e42a3632003cc5c1c7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -5,9 +5,9 @@ using UnityEngine;
|
||||
public abstract class ModuleScene : MonoBehaviour {
|
||||
protected virtual ModuleCore ModuleCore => ModuleCore.I;
|
||||
protected virtual void Awake() {
|
||||
if (ModuleCore.ModuleScene != null) { Destroy(gameObject); return; }
|
||||
ModuleCore.ModuleScene = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
//if (ModuleCore.ModuleScene != null) { Destroy(gameObject); return; }
|
||||
//ModuleCore.ModuleScene = this;
|
||||
//DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
public virtual void LoadSceneAsync(string scene) {
|
||||
StartCoroutine(ILoadSceneAsync(scene));
|
||||
|
||||
@@ -5,15 +5,14 @@ using UnityEngine.UIElements;
|
||||
|
||||
public abstract class ModuleUIPage : MonoBehaviour {
|
||||
public UIDocument document;
|
||||
/// <summary> 根目录文档 </summary>
|
||||
public VisualElement root => document.rootVisualElement;
|
||||
|
||||
/// <summary> 必须初始化 </summary>
|
||||
protected abstract void Awake();
|
||||
/// <summary> 核心模块 </summary>
|
||||
protected virtual ModuleCore ModuleCore => ModuleCore.I;
|
||||
protected virtual void Awake() => ModuleCore.FunctionRegister(this);
|
||||
|
||||
public void Add(VisualElement child) {
|
||||
root.Add(child);
|
||||
}
|
||||
public T Q<T>(string name = null, string className = null) where T : VisualElement {
|
||||
return root.Q<T>(name, className);
|
||||
}
|
||||
/// <summary> 添加UI元素 </summary>
|
||||
public void Add(VisualElement child) => root.Add(child);
|
||||
/// <summary> 查询UI元素 </summary>
|
||||
public T Q<T>(string name = null, string className = null) where T : VisualElement => root.Q<T>(name, className);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 56be1d651140a1d4fb90c3fb34136a4b
|
||||
guid: a81cd0646bee3624b941f3d0b2c272f4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class ModuleUIWindow<Data> : MonoBehaviour {
|
||||
/// <summary> 绑定的页面 </summary>
|
||||
public ModuleUIPage ModuleUIPage;
|
||||
/// <summary> 必须初始化 </summary>
|
||||
public abstract void Awake();
|
||||
/// <summary> 核心模块 </summary>
|
||||
protected virtual ModuleCore ModuleCore => ModuleCore.I;
|
||||
/// <summary> 打开模块,并且传进参数 </summary>
|
||||
public abstract void Open(Data data);
|
||||
/// <summary> 关闭模块 </summary>
|
||||
public abstract void Close();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 928a5dbb2497f0145b1da8645720ac89
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,33 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class ModuleViewCamera : MonoBehaviour {
|
||||
/// <summary> 视图空间位置 </summary>
|
||||
public abstract Vector3 Position { get; set; }
|
||||
/// <summary> 视图空间旋转 </summary>
|
||||
public abstract Vector3 EulerAngles { get; set; }
|
||||
/// <summary> 视图空间缩放 </summary>
|
||||
public abstract Vector3 LocalScale { get; set; }
|
||||
/// <summary> 相机正交大小 </summary>
|
||||
public abstract float OrthographicSize { get; set; }
|
||||
/// <summary> 当前视图空间的中心点 </summary>
|
||||
public abstract Vector3 CurrentViewSpaceCenter { get; }
|
||||
/// <summary> 相机的世界位置 </summary>
|
||||
public abstract Vector3 CameraWorldPosition { get; }
|
||||
/// <summary> 渲染纹理 </summary>
|
||||
public abstract RenderTexture RenderTexture { get; }
|
||||
|
||||
protected abstract void Awake();
|
||||
|
||||
protected virtual ModuleCore ModuleCore => ModuleCore.I;
|
||||
|
||||
/// <summary> 更新渲染纹理 </summary>
|
||||
public abstract void UpdateRenderTexture(int x, int y);
|
||||
/// <summary> 屏幕坐标转换世界坐标 </summary>
|
||||
public abstract Vector2 ScreenToWorldPosition(Vector2 screenPosition);
|
||||
/// <summary> 屏幕坐标转换世界坐标 (0-1) </summary>
|
||||
public abstract Vector2 ScreenToViewPosition(Vector2 screenPosition);
|
||||
/// <summary> 从屏幕坐标发射一条射线 </summary>
|
||||
public abstract Ray ScreenPointToRay(Vector2 screenPosition);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93bd8c351a140654da540f55d0d7091f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public abstract class ModuleViewInput : MonoBehaviour {
|
||||
/// <summary> 主键输入模块类型 </summary>
|
||||
public abstract event Action<Type> OnInputType;
|
||||
/// <summary> 必须要初始化 </summary>
|
||||
protected abstract void Awake();
|
||||
/// <summary> 核心模块 </summary>
|
||||
protected virtual ModuleCore ModuleCore => ModuleCore.I;
|
||||
|
||||
public abstract void SetPrimaryKeyInput<T>(T inputUnit) where T : ModuleViewInputUnit;
|
||||
|
||||
/// <summary> 按下鼠标左键 </summary>
|
||||
public abstract void DownLeftMouse(DataMouseInput data);
|
||||
/// <summary> 拖拽鼠标左键 </summary>
|
||||
public abstract void DragLeftMouse(DataMouseInput data);
|
||||
/// <summary> 移动鼠标左键 </summary>
|
||||
public abstract void MoveLeftMouse(DataMouseInput data);
|
||||
/// <summary> 释放鼠标左键 </summary>
|
||||
public abstract void ReleaseLeftMouse(DataMouseInput data);
|
||||
|
||||
/// <summary> 按下鼠标右键 </summary>
|
||||
public abstract void DownRightMouse(DataMouseInput data);
|
||||
/// <summary> 拖拽鼠标右键 </summary>
|
||||
public abstract void DragRightMouse(DataMouseInput data);
|
||||
/// <summary> 移动鼠标右键 </summary>
|
||||
public abstract void MoveRightMouse(DataMouseInput data);
|
||||
/// <summary> 释放鼠标右键 </summary>
|
||||
public abstract void ReleaseRightMouse(DataMouseInput data);
|
||||
|
||||
/// <summary> 按下鼠标中键 </summary>
|
||||
public abstract void DownMiddleMouse(DataMouseInput data);
|
||||
/// <summary> 拖拽鼠标中键 </summary>
|
||||
public abstract void DragMiddleMouse(DataMouseInput data);
|
||||
/// <summary> 移动鼠标中键 </summary>
|
||||
public abstract void MoveMiddleMouse(DataMouseInput data);
|
||||
/// <summary> 释放鼠标中键 </summary>
|
||||
public abstract void ReleaseMiddleMouse(DataMouseInput data);
|
||||
|
||||
/// <summary> 鼠标滚轮 </summary>
|
||||
public abstract void ScrollWheel(DataMouseInput data);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f56f94c154ec7d84eb464a1509810d78
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9ce7a65aa37a4934ba8d85a6136d8c32
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DataDesignPoint {
|
||||
public readonly DataPlate dataPlate;
|
||||
public DataDesignPoint(DataPlate dataPlate) { this.dataPlate = dataPlate; }
|
||||
|
||||
public int index;
|
||||
public Vector2 postiton;
|
||||
public Vector2 leftBezier;//贝塞尔曲线左(逆时针+)
|
||||
public Vector2 rightBezier;//贝塞尔曲线右(顺时针-)
|
||||
public List<Vector2> edgePoints = new List<Vector2>();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 215036ac2145e9f45835ea28080aee53
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PrefabBezierPoint : MonoBehaviour {
|
||||
public LineRenderer bezierLine;
|
||||
private Vector2 position;
|
||||
private DataDesignPoint value;
|
||||
private Action<Vector2> callback;
|
||||
public DataPlate DataPlate => value.dataPlate;
|
||||
public Vector2 Position => position + value.postiton;
|
||||
public void SetValue(DataDesignPoint value, Action<Vector2> callback) {
|
||||
this.value = value;
|
||||
this.callback = callback;
|
||||
}
|
||||
public void SetPosition(Vector2 position) {
|
||||
this.position = position;
|
||||
float lx = position.x * 50;
|
||||
float ly = position.y * 50;
|
||||
transform.localPosition = new Vector3(lx, ly, transform.localPosition.z);
|
||||
bezierLine.SetPosition(1, position);
|
||||
}
|
||||
public void Change(Vector2 localPosition) {
|
||||
Vector2 position = localPosition - value.postiton;
|
||||
SetPosition(position);
|
||||
callback?.Invoke(position);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a3d9fd1b34a70c4ca6a4edaf6715131
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,54 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MuHua;
|
||||
|
||||
public class PrefabDesignPoint : MonoBehaviour, ITemplate<DataDesignPoint> {
|
||||
public LineRenderer lineRenderer;
|
||||
public EdgeCollider2D edgeCollider;
|
||||
|
||||
public PrefabBezierPoint bezierPoint1;
|
||||
public PrefabBezierPoint bezierPoint2;
|
||||
|
||||
private DataDesignPoint value;
|
||||
public int Index => value.index;
|
||||
public Vector2 Position => value.postiton;
|
||||
public List<Vector2> EdgePoints => value.edgePoints;
|
||||
public DataPlate DataPlate => value.dataPlate;
|
||||
public int MaxIndex => DataPlate.designPoints.Count;
|
||||
public int NextIndex => DataPlateTool.NormalIndex(Index + 1, MaxIndex);
|
||||
public void SetValue(DataDesignPoint value) {
|
||||
this.value = value;
|
||||
bezierPoint1.SetValue(value, (obj) => { value.leftBezier = obj; });
|
||||
bezierPoint2.SetValue(value, (obj) => { value.rightBezier = obj; });
|
||||
DataPlate.OnChangeDesignPoint += DataPlate_OnChangeDesignPoint;
|
||||
DataPlate_OnChangeDesignPoint(Index);
|
||||
}
|
||||
private void OnDestroy() {
|
||||
DataPlate.OnChangeDesignPoint -= DataPlate_OnChangeDesignPoint;
|
||||
}
|
||||
private void DataPlate_OnChangeDesignPoint(int index) {
|
||||
if (index != Index) { return; }
|
||||
transform.localPosition = Position;
|
||||
//添加全部点
|
||||
int maxIndex = EdgePoints.Count + 1;
|
||||
lineRenderer.positionCount = maxIndex;
|
||||
Vector2[] vectors = new Vector2[maxIndex];
|
||||
for (int i = 0; i < EdgePoints.Count; i++) {
|
||||
Vector2 position = EdgePoints[i] - Position;
|
||||
lineRenderer.SetPosition(i, position);
|
||||
vectors[i] = position;
|
||||
}
|
||||
//添加最后一个点
|
||||
int last = maxIndex - 1;
|
||||
DataDesignPoint nextDesignPoint = DataPlate.FindDesignPoint(NextIndex);
|
||||
Vector2 position2 = nextDesignPoint.postiton - Position;
|
||||
lineRenderer.SetPosition(last, position2);
|
||||
vectors[last] = position2;
|
||||
//更新2D线段碰撞器
|
||||
edgeCollider.points = vectors;
|
||||
//更新贝塞尔曲线
|
||||
bezierPoint1.SetPosition(value.leftBezier);
|
||||
bezierPoint2.SetPosition(value.rightBezier);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 76c13895912b8cd48a099779cbd0af65
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
public class DataMouseInput {
|
||||
public Vector3 ScreenPosition;
|
||||
public float ScrollWheel;
|
||||
public DataMouseInput(MouseDownEvent evt) {
|
||||
ScreenPosition = evt.localMousePosition;
|
||||
}
|
||||
public DataMouseInput(MouseMoveEvent evt) {
|
||||
ScreenPosition = evt.localMousePosition;
|
||||
}
|
||||
public DataMouseInput(MouseUpEvent evt) {
|
||||
ScreenPosition = evt.localMousePosition;
|
||||
}
|
||||
public DataMouseInput(MouseOutEvent evt) {
|
||||
ScreenPosition = evt.localMousePosition;
|
||||
}
|
||||
public DataMouseInput(WheelEvent evt) {
|
||||
ScreenPosition = evt.localMousePosition;
|
||||
ScrollWheel = evt.delta.y;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d06cc200114296b4c9aef60a8def59b9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9716b7730eb4544cae971a8de6cf9d4
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DataPlate {
|
||||
public Action OnChange;
|
||||
public Action<int> OnChangeDesignPoint;
|
||||
public Action<int> OnChangeEdgePoint;
|
||||
|
||||
/// <summary> 边缘平滑度 </summary>
|
||||
public float edgeSmooth = 0.01f;
|
||||
/// <summary> 设计点 </summary>
|
||||
public List<DataDesignPoint> designPoints = new List<DataDesignPoint>();
|
||||
|
||||
/// <summary> 模型中心点偏移 </summary>
|
||||
public Vector3 centerOffset;
|
||||
/// <summary> 边缘点 </summary>
|
||||
public List<Vector2> edgePoints = new List<Vector2>();
|
||||
|
||||
//平面网格数据
|
||||
/// <summary> 顶点 </summary>
|
||||
public List<Vector3> vertices = new List<Vector3>();
|
||||
/// <summary> UV </summary>
|
||||
public List<Vector2> uv = new List<Vector2>();
|
||||
/// <summary> 三角形 </summary>
|
||||
public List<int> triangles = new List<int>();
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f57f20fad19ed740adccdb0da9c4469
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,61 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MuHua;
|
||||
|
||||
public class PrefabPlate : MonoBehaviour, ITemplate<DataPlate> {
|
||||
public Transform DesignPointParent;
|
||||
public Transform DesignPointTemplate;
|
||||
public Transform PlateEdgeParent;
|
||||
public Transform PlateEdgeTemplate;
|
||||
|
||||
private DataPlate value;
|
||||
private Vector3 localPosition;
|
||||
|
||||
public MeshFilter MeshFilter => GetComponent<MeshFilter>();
|
||||
public MeshCollider MeshCollider => GetComponent<MeshCollider>();
|
||||
public ModuleViewCamera viewCamera => ModuleCore.I.PlateDesignViewCamera;
|
||||
public void SetValue(DataPlate value) {
|
||||
this.value = value;
|
||||
localPosition = viewCamera.CurrentViewSpaceCenter;
|
||||
value.OnChange += DataPlate_OnChange;
|
||||
value.Compute();
|
||||
}
|
||||
private void OnDestroy() {
|
||||
value.OnChange -= DataPlate_OnChange;
|
||||
}
|
||||
public void DataPlate_OnChange() {
|
||||
CreateDesignPoint();
|
||||
//CreatePrefabEdgePoint();
|
||||
CreatePolygonMesh();
|
||||
//重置坐标
|
||||
transform.localPosition = localPosition + value.centerOffset;
|
||||
localPosition = transform.localPosition;
|
||||
}
|
||||
/// <summary> 生成设计点 </summary>
|
||||
private void CreateDesignPoint() {
|
||||
DesignPointParent.Instantiate(DesignPointTemplate, value.designPoints);
|
||||
}
|
||||
/// <summary> 生成边缘点 </summary>
|
||||
private void CreatePrefabEdgePoint() {
|
||||
PlateEdgeParent.DestroySon(PlateEdgeTemplate);
|
||||
for (int i = 0; i < value.edgePoints.Count; i++) {
|
||||
Transform temp = Instantiate(PlateEdgeTemplate, PlateEdgeParent);
|
||||
temp.gameObject.SetActive(true);
|
||||
PrefabPlateEdge plateEdge = temp.GetComponent<PrefabPlateEdge>();
|
||||
plateEdge.SetValue(i, value);
|
||||
}
|
||||
}
|
||||
/// <summary> 生成网格 </summary>
|
||||
private void CreatePolygonMesh() {
|
||||
Mesh mesh = new Mesh();
|
||||
mesh.vertices = value.vertices.ToArray();
|
||||
mesh.uv = value.uv.ToArray();
|
||||
mesh.triangles = value.triangles.ToArray();
|
||||
mesh.RecalculateBounds();
|
||||
mesh.RecalculateNormals();
|
||||
mesh.RecalculateTangents();
|
||||
MeshFilter.mesh = mesh;
|
||||
MeshCollider.sharedMesh = mesh;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efaf2ad171011c7448092aa48eaf41c4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,34 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MuHua;
|
||||
|
||||
public class PrefabPlateEdge : MonoBehaviour {
|
||||
public LineRenderer lineRenderer;
|
||||
public EdgeCollider2D edgeCollider;
|
||||
|
||||
[HideInInspector] public int index;
|
||||
[HideInInspector] public DataPlate value;
|
||||
|
||||
public int MaxIndex => value.edgePoints.Count;
|
||||
public int NextIndex => DataPlateTool.NormalIndex(index + 1, MaxIndex);
|
||||
public Vector3 CurrentPosition => value.FindEdgePoint(index);
|
||||
public Vector3 NextPosition => value.FindEdgePoint(NextIndex);
|
||||
public void SetValue(int index, DataPlate value) {
|
||||
this.index = index;
|
||||
this.value = value;
|
||||
value.OnChangeEdgePoint += UpdateLineRenderer;
|
||||
UpdateLineRenderer(index);
|
||||
}
|
||||
private void OnDestroy() {
|
||||
value.OnChangeEdgePoint -= UpdateLineRenderer;
|
||||
}
|
||||
public void UpdateLineRenderer(int index) {
|
||||
if (index != this.index && index != NextIndex) { return; }
|
||||
transform.localPosition = CurrentPosition;
|
||||
|
||||
Vector3 direction = NextPosition - CurrentPosition;
|
||||
lineRenderer.SetPosition(1, direction);
|
||||
edgeCollider.points = new Vector2[] { Vector2.zero, direction };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e74baea99ddf044c8a16b4d0eacf8ca
|
||||
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;
|
||||
|
||||
[CreateAssetMenu(fileName = "PresetsPlate", menuName = "数据模块/预设模板")]
|
||||
public class DataPresetsPlate : ScriptableObject {
|
||||
public List<Vector2> designPoints;
|
||||
public DataPlate ToPlate() {
|
||||
DataPlate data = new DataPlate();
|
||||
data.designPoints = new List<DataDesignPoint>();
|
||||
int maxIndex = designPoints.Count;
|
||||
for (int i = 0; i < designPoints.Count; i++) {
|
||||
Vector2 position = designPoints[i];
|
||||
int left = DataPlateTool.NormalIndex(i + 1, maxIndex);
|
||||
int right = DataPlateTool.NormalIndex(i - 1, maxIndex);
|
||||
Vector2 leftBezier = (designPoints[left] - position) * 0.5f;
|
||||
Vector2 rightBezier = (designPoints[right] - position) * 0.5f;
|
||||
DataDesignPoint designPoint = CreateDataDesignPoint(i, position, data);
|
||||
designPoint.leftBezier = leftBezier;
|
||||
designPoint.rightBezier = rightBezier;
|
||||
data.designPoints.Add(designPoint);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
private DataDesignPoint CreateDataDesignPoint(int index, Vector2 position, DataPlate data) {
|
||||
DataDesignPoint designPoint = new DataDesignPoint(data);
|
||||
designPoint.index = index;
|
||||
designPoint.postiton = position;
|
||||
return designPoint;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: de9e8e0217c52a447a49c55f818131ef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eda56199f140e8e41bde06c79efd4b8e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,54 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 算法:中心角度排序法
|
||||
/// 依据:???
|
||||
/// </summary>
|
||||
public class AlgorithmEdge : ModuleAlgorithm<DataPlate> {
|
||||
/// <summary> 算法:中心角度排序法 </summary>
|
||||
public AlgorithmEdge() { }
|
||||
|
||||
public class EdgeAngle {
|
||||
public float angle;
|
||||
public Vector3 position;
|
||||
}
|
||||
|
||||
public override void Compute(DataPlate data) {
|
||||
List<Vector2> edgePoints = data.edgePoints;
|
||||
//计算多边形中心点
|
||||
float x = edgePoints.Average((v3) => v3.x);
|
||||
float y = edgePoints.Average((v3) => v3.y);
|
||||
Vector2 center = new Vector2(x, y);
|
||||
//计算所有点的夹角
|
||||
Vector3 direction = edgePoints[0] - center;
|
||||
List<EdgeAngle> angleList = new List<EdgeAngle>();
|
||||
for (int i = 0; i < edgePoints.Count; i++) {
|
||||
Vector3 normal = edgePoints[i] - center;
|
||||
EdgeAngle edgeAngle = new EdgeAngle();
|
||||
edgeAngle.angle = Angle(direction, normal);
|
||||
edgeAngle.position = normal;
|
||||
angleList.Add(edgeAngle);
|
||||
}
|
||||
data.centerOffset = center;
|
||||
//排序
|
||||
angleList.Sort((x, y) => x.angle.CompareTo(y.angle));
|
||||
//把排序好的边缘点重新添加
|
||||
data.edgePoints = new List<Vector2>();
|
||||
for (int i = 0; i < angleList.Count; i++) {
|
||||
data.edgePoints.Add(angleList[i].position);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 计算两点夹角
|
||||
/// </summary>
|
||||
/// <param name="direction">0度点位置</param>
|
||||
/// <param name="position">目标点</param>
|
||||
/// <returns></returns>
|
||||
private float Angle(Vector3 direction, Vector3 position) {
|
||||
float angle = Vector2.SignedAngle(direction, position);
|
||||
return angle;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d17cdf61cce7657489b657640646a786
|
||||
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;
|
||||
|
||||
/// <summary>
|
||||
/// 算法:根据设计点来生成边缘点
|
||||
/// 依据:???
|
||||
/// </summary>
|
||||
public class AlgorithmGenerateEdge : ModuleAlgorithm<DataPlate> {
|
||||
/// <summary> 算法:根据设计点来生成边缘点 </summary>
|
||||
public AlgorithmGenerateEdge() { }
|
||||
|
||||
public override void Compute(DataPlate data) {
|
||||
data.edgePoints = new List<Vector2>();
|
||||
int maxIndex = data.designPoints.Count;
|
||||
for (int i = 0; i < maxIndex; i++) {
|
||||
DataDesignPoint designPoint = data.FindDesignPoint(i);
|
||||
DataDesignPoint nextDesignPoint = data.FindDesignPoint(i + 1);
|
||||
CreateStraightLine(data, designPoint, nextDesignPoint);
|
||||
}
|
||||
}
|
||||
public void CreateStraightLine(DataPlate data, DataDesignPoint designPoint, DataDesignPoint nextDesignPoint) {
|
||||
designPoint.edgePoints = new List<Vector2>();
|
||||
//方向,距离
|
||||
Vector2 direction = (nextDesignPoint.postiton - designPoint.postiton).normalized;
|
||||
float distance = Vector2.Distance(nextDesignPoint.postiton, designPoint.postiton);
|
||||
//求余,得商数
|
||||
int a = (int)(distance * 1000);
|
||||
int b = (int)(data.edgeSmooth * 1000);
|
||||
int quotient = Math.DivRem(a, b, out int remainder);
|
||||
//点位间距
|
||||
float segment = distance / quotient;
|
||||
Vector3 ap = designPoint.postiton;
|
||||
Vector3 bp = designPoint.leftBezier + designPoint.postiton;
|
||||
Vector3 cp = nextDesignPoint.rightBezier + nextDesignPoint.postiton;
|
||||
Vector3 dp = nextDesignPoint.postiton;
|
||||
for (int i = 0; i < quotient; i++) {
|
||||
float t = segment * i / distance;
|
||||
Vector2 position = ComputeBezier(ap, bp, cp, dp, t);
|
||||
designPoint.edgePoints.Add(position);
|
||||
}
|
||||
data.edgePoints.AddRange(designPoint.edgePoints);
|
||||
}
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="a">起点</param>
|
||||
/// <param name="b">起点的贝塞尔点</param>
|
||||
/// <param name="c">终点的贝塞尔点</param>
|
||||
/// <param name="d">终点</param>
|
||||
/// <param name="t">进度</param>
|
||||
/// <returns></returns>
|
||||
public Vector3 ComputeBezier(Vector3 a, Vector3 b, Vector3 c, Vector3 d, float t) {
|
||||
Vector3 aa = a + (b - a) * t;
|
||||
Vector3 bb = b + (c - b) * t;
|
||||
Vector3 cc = c + (d - c) * t;
|
||||
|
||||
Vector3 aaa = aa + (bb - aa) * t;
|
||||
Vector3 bbb = bb + (cc - bb) * t;
|
||||
return aaa + (bbb - aaa) * t;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d0c7458fc5119243b7db98671184058
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,186 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 算法:耳切法
|
||||
/// 依据:简单多边形的双耳定理
|
||||
/// </summary>
|
||||
public class AlgorithmPolygon : ModuleAlgorithm<DataPlate> {
|
||||
/// <summary> 算法:耳切法 </summary>
|
||||
public AlgorithmPolygon() { }
|
||||
|
||||
public enum AngleType {
|
||||
/// <summary> 平角 = 180 </summary>
|
||||
StraightAngle = 0,
|
||||
/// <summary> 优角 >180 </summary>
|
||||
ReflexAngle = 1,
|
||||
/// <summary> 劣角 <180 </summary>
|
||||
InferiorAngle = 2
|
||||
}
|
||||
|
||||
public class PointNode {
|
||||
public int index;
|
||||
public Vector2 Position;
|
||||
public Vector2 PreviousPosition;
|
||||
public Vector2 NextPosition;
|
||||
}
|
||||
|
||||
public class Triangle {
|
||||
public Vector2 a;
|
||||
public Vector2 b;
|
||||
public Vector2 c;
|
||||
}
|
||||
|
||||
public override void Compute(DataPlate data) {
|
||||
List<Vector2> edgePoints = new List<Vector2>(data.edgePoints);
|
||||
List<Triangle> polygons = new List<Triangle>();
|
||||
Vector2[] allArray = edgePoints.ToArray();
|
||||
bool isClockWise = IsClockWise(allArray);
|
||||
//耳切法生成三角形
|
||||
ComputeEarTriangle(polygons, edgePoints, allArray, isClockWise);
|
||||
MergeTriangles(data, polygons);
|
||||
}
|
||||
/// <summary> 循环计算耳点 </summary>
|
||||
public void ComputeEarTriangle(List<Triangle> polygons, List<Vector2> edgePoints, Vector2[] allArray, bool isClockWise) {
|
||||
List<Triangle> temp = ComputeEarTriangle(edgePoints, allArray, isClockWise);
|
||||
if (temp.Count == 0) { return; }
|
||||
polygons.AddRange(temp);
|
||||
ComputeEarTriangle(polygons, edgePoints, allArray, isClockWise);
|
||||
}
|
||||
/// <summary> 计算一个耳点 </summary>
|
||||
public List<Triangle> ComputeEarTriangle(List<Vector2> edgePoints, Vector2[] allArray, bool isClockWise) {
|
||||
Vector2[] array = edgePoints.ToArray();
|
||||
List<Triangle> polygons = new List<Triangle>();
|
||||
for (int i = 0; i < array.Length; i++) {
|
||||
PointNode pointNode = CreatePointNode(i, array);
|
||||
AngleType angleType = GetAngleType(pointNode, isClockWise);
|
||||
// 等于180,不可能为耳点
|
||||
if (angleType == AngleType.StraightAngle) { continue; }
|
||||
// 大于180,不可能为耳点
|
||||
if (angleType == AngleType.ReflexAngle) { continue; }
|
||||
// 包含其他点,不可能为耳点
|
||||
if (IsInsideTriangle(pointNode, allArray)) { continue; }
|
||||
// 包含其他耳点,不可能成为耳点
|
||||
if (!IsInsideEarTriangle(pointNode, edgePoints)) { continue; }
|
||||
edgePoints.Remove(pointNode.Position);
|
||||
polygons.Add(CreateTriangle(pointNode));
|
||||
}
|
||||
return polygons;
|
||||
}
|
||||
/// <summary> 创建节点 </summary>
|
||||
public PointNode CreatePointNode(int index, Vector2[] array) {
|
||||
int maxIndex = array.Length;
|
||||
PointNode pointNode = new PointNode();
|
||||
pointNode.index = index;
|
||||
pointNode.PreviousPosition = array[NormalIndex(index - 1, maxIndex)];
|
||||
pointNode.Position = array[NormalIndex(index + 0, maxIndex)];
|
||||
pointNode.NextPosition = array[NormalIndex(index + 1, maxIndex)];
|
||||
return pointNode;
|
||||
}
|
||||
/// <summary> 计算三角形内是否包含其他点 </summary>
|
||||
public bool IsInsideTriangle(PointNode node, Vector2[] array) {
|
||||
for (int i = 0; i < array.Length; i++) {
|
||||
if (array[i] == node.Position) { continue; }
|
||||
if (array[i] == node.PreviousPosition) { continue; }
|
||||
if (array[i] == node.NextPosition) { continue; }
|
||||
if (IsInsideTriangle(node, array[i])) { return true; }
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/// <summary> 计算三角形内是否包含其他点 </summary>
|
||||
public bool IsInsideEarTriangle(PointNode node, List<Vector2> edgePoints) {
|
||||
if (!edgePoints.Contains(node.Position)) { return false; }
|
||||
if (!edgePoints.Contains(node.PreviousPosition)) { return false; }
|
||||
if (!edgePoints.Contains(node.NextPosition)) { return false; }
|
||||
return true;
|
||||
}
|
||||
/// <summary> 从节点创建三角形 </summary>
|
||||
public Triangle CreateTriangle(PointNode node) {
|
||||
Triangle triangle = new Triangle();
|
||||
triangle.a = node.Position;
|
||||
triangle.b = node.PreviousPosition;
|
||||
triangle.c = node.NextPosition;
|
||||
return triangle;
|
||||
}
|
||||
/// <summary> 合并三角形 </summary>
|
||||
public void MergeTriangles(DataPlate data, List<Triangle> polygons) {
|
||||
//创建数据容器
|
||||
List<Vector3> vertices = new List<Vector3>();
|
||||
List<Vector2> uv = new List<Vector2>();
|
||||
List<int> triangles = new List<int>();
|
||||
//三角形合并
|
||||
for (int i = 0; i < polygons.Count; i++) {
|
||||
Vector3 a = polygons[i].a;
|
||||
int aIndex = vertices.Count - 1;
|
||||
if (!vertices.Contains(a)) { vertices.Add(a); aIndex = vertices.Count - 1; }
|
||||
else { aIndex = vertices.IndexOf(a); }
|
||||
|
||||
Vector3 b = polygons[i].b;
|
||||
int bIndex = vertices.Count - 1;
|
||||
if (!vertices.Contains(b)) { vertices.Add(b); bIndex = vertices.Count - 1; }
|
||||
else { bIndex = vertices.IndexOf(b); }
|
||||
|
||||
Vector3 c = polygons[i].c;
|
||||
int cIndex = vertices.Count - 1;
|
||||
if (!vertices.Contains(c)) { vertices.Add(c); cIndex = vertices.Count - 1; }
|
||||
else { cIndex = vertices.IndexOf(c); }
|
||||
|
||||
triangles.Add(aIndex);
|
||||
triangles.Add(bIndex);
|
||||
triangles.Add(cIndex);
|
||||
}
|
||||
//展开uv (顶点去掉z坐标就是未缩放的平面UV)
|
||||
for (int i = 0; i < vertices.Count; i++) { uv.Add(vertices[i]); }
|
||||
//附加数据
|
||||
data.vertices = vertices;
|
||||
data.uv = uv;
|
||||
data.triangles = triangles;
|
||||
}
|
||||
|
||||
/// <summary> 头尾循环标准化索引 </summary>
|
||||
public static int NormalIndex(int index, int maxIndex) {
|
||||
if (maxIndex == 0) { Debug.LogError("错误索引:maxIndex = 0"); return 0; }
|
||||
if (index < 0) { return NormalIndex(index + maxIndex, maxIndex); }
|
||||
if (index >= maxIndex) { return NormalIndex(index - maxIndex, maxIndex); }
|
||||
return index;
|
||||
}
|
||||
/// <summary> 当前的点方向是否为顺时针 </summary>
|
||||
public static bool IsClockWise(Vector2[] array) {
|
||||
// 通过计算叉乘来确定方向
|
||||
float sum = 0f;
|
||||
double count = array.Length;
|
||||
Vector3 va, vb;
|
||||
for (int i = 0; i < array.Length; i++) {
|
||||
va = array[i];
|
||||
vb = (i == count - 1) ? array[0] : array[i + 1];
|
||||
sum += va.x * vb.y - va.y * vb.x;
|
||||
}
|
||||
return sum < 0;
|
||||
}
|
||||
/// <summary> 判断角的类型 </summary>
|
||||
public static AngleType GetAngleType(PointNode node, bool isClockWise) {
|
||||
// 角度是否小于180
|
||||
// oa & ob 之间的夹角,(右手法则)
|
||||
// 逆时针顺序是相反的
|
||||
Vector2 o = node.Position;
|
||||
Vector2 a = node.PreviousPosition;
|
||||
Vector2 b = node.NextPosition;
|
||||
float f = (a.x - o.x) * (b.y - o.y) - (a.y - o.y) * (b.x - o.x);
|
||||
bool flag = isClockWise ? f > 0 : f < 0;
|
||||
if (f == 0) { return AngleType.StraightAngle; }
|
||||
else if (flag) { return AngleType.InferiorAngle; }
|
||||
else { return AngleType.ReflexAngle; }
|
||||
}
|
||||
/// <summary> p点是否在点和其左右两个点组成的三角形内,或ca,cb边上 </summary>
|
||||
public static bool IsInsideTriangle(PointNode node, Vector2 p) {
|
||||
// p点是否在abc三角形内
|
||||
Vector2 a = node.PreviousPosition;
|
||||
Vector2 b = node.NextPosition;
|
||||
Vector2 c = node.Position;
|
||||
float c1 = (b.x - a.x) * (p.y - b.y) - (b.y - a.y) * (p.x - b.x);
|
||||
float c2 = (c.x - b.x) * (p.y - c.y) - (c.y - b.y) * (p.x - c.x);
|
||||
float c3 = (a.x - c.x) * (p.y - a.y) - (a.y - c.y) * (p.x - a.x);
|
||||
return (c1 > 0f && c2 >= 0f && c3 >= 0f) || (c1 < 0f && c2 <= 0f && c3 <= 0f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad1a08fdeb67d3048a88c3668e3b6764
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 485602713f4e17344b5dc7f627ed1a81
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AssetsPresetsPlate : ModuleAssets<DataPresetsPlate> {
|
||||
protected override void Awake() {
|
||||
ModuleCore.PresetsPlateAssets = this;
|
||||
}
|
||||
public override void ForEach(Action<DataPresetsPlate> action) {
|
||||
assets.ForEach(action);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8198c73995924524d985c3beb338f033
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -3,10 +3,7 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class EnumeratorAgent : ModuleAgent {
|
||||
public override void AgentLoadingNetwork(DataNetwork data) {
|
||||
StartCoroutine(data.IWebRequest());
|
||||
}
|
||||
public override void AgentNetwork(DataNetwork data) {
|
||||
StartCoroutine(data.IWebRequest());
|
||||
protected override void Awake() {
|
||||
ModuleCore.ModuleAgent = this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f14f51c40117cc4db70bd544f9ee461
|
||||
guid: e79a947f40825b54a8b65cb2714fbe6e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
||||
@@ -15,7 +15,7 @@ public class UICuttingWorkshop : ModuleUIPage {
|
||||
private Button Button4 => root.Q<Button>("Button4");
|
||||
private Button Button5 => root.Q<Button>("Button5");
|
||||
protected override void Awake() {
|
||||
base.Awake();
|
||||
ModuleCore.FunctionRegister(this);
|
||||
Button1.clicked += Button1_clicked;
|
||||
Button2.clicked += Button2_clicked;
|
||||
Button3.clicked += Button3_clicked;
|
||||
@@ -23,18 +23,18 @@ public class UICuttingWorkshop : ModuleUIPage {
|
||||
Button5.clicked += Button5_clicked;
|
||||
}
|
||||
private void Button1_clicked() {
|
||||
ModuleCore.ModuleScene.LoadSceneAsync(scene1);
|
||||
//ModuleCore.ModuleScene.LoadSceneAsync(scene1);
|
||||
}
|
||||
private void Button2_clicked() {
|
||||
ModuleCore.ModuleScene.LoadSceneAsync(scene2);
|
||||
//ModuleCore.ModuleScene.LoadSceneAsync(scene2);
|
||||
}
|
||||
private void Button3_clicked() {
|
||||
ModuleCore.ModuleScene.LoadSceneAsync(scene3);
|
||||
//ModuleCore.ModuleScene.LoadSceneAsync(scene3);
|
||||
}
|
||||
private void Button4_clicked() {
|
||||
ModuleCore.ModuleScene.LoadSceneAsync(returnScene);
|
||||
//ModuleCore.ModuleScene.LoadSceneAsync(returnScene);
|
||||
}
|
||||
private void Button5_clicked() {
|
||||
ModuleCore.LearningVideoPanel.Open(null);
|
||||
//ModuleCore.LearningVideoPanel.Open(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public class UIFactoryScenery : ModuleUIPage {
|
||||
private Button Button4 => root.Q<Button>("Button4");
|
||||
private MUFoldout Foldout => root.Q<MUFoldout>("MUFoldout");
|
||||
protected override void Awake() {
|
||||
base.Awake();
|
||||
ModuleCore.FunctionRegister(this);
|
||||
Button1.clicked += Button1_clicked;
|
||||
Button2.clicked += Button2_clicked;
|
||||
Button3.clicked += Button3_clicked;
|
||||
@@ -32,7 +32,7 @@ public class UIFactoryScenery : ModuleUIPage {
|
||||
Debug.Log("地图导航");
|
||||
}
|
||||
private void Button4_clicked() {
|
||||
ModuleCore.ModuleScene.LoadSceneAsync(returnScene);
|
||||
//ModuleCore.ModuleScene.LoadSceneAsync(returnScene);
|
||||
}
|
||||
public void CreateUINavigationUnit(NavigationData data) {
|
||||
VisualElement element = NavigationUnitlAsset.Instantiate();
|
||||
@@ -57,6 +57,6 @@ public class UINavigationUnit {
|
||||
Button.clicked += Button_clicked;
|
||||
}
|
||||
private void Button_clicked() {
|
||||
ModuleCore.ModuleScene.LoadSceneAsync(value.scene);
|
||||
//ModuleCore.ModuleScene.LoadSceneAsync(value.scene);
|
||||
}
|
||||
}
|
||||
@@ -3,5 +3,7 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class UIGlobalPage : ModuleUIPage {
|
||||
|
||||
protected override void Awake() {
|
||||
ModuleCore.FunctionRegister(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,5 +3,7 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class UILoginInterface : ModuleUIPage {
|
||||
|
||||
protected override void Awake() {
|
||||
ModuleCore.FunctionRegister(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,31 +5,31 @@ using UnityEngine.UIElements;
|
||||
using MuHua;
|
||||
|
||||
public class UISewingWorkshop : ModuleUIPage {
|
||||
[SceneName]public string scene1;
|
||||
[SceneName]public string scene2;
|
||||
[SceneName]public string scene3;
|
||||
[SceneName]public string returnScene;
|
||||
[SceneName] public string scene1;
|
||||
[SceneName] public string scene2;
|
||||
[SceneName] public string scene3;
|
||||
[SceneName] public string returnScene;
|
||||
private Button Button1 => root.Q<Button>("Button1");
|
||||
private Button Button2 => root.Q<Button>("Button2");
|
||||
private Button Button3 => root.Q<Button>("Button3");
|
||||
private Button Button4 => root.Q<Button>("Button4");
|
||||
protected override void Awake() {
|
||||
base.Awake();
|
||||
ModuleCore.FunctionRegister(this);
|
||||
Button1.clicked += Button1_clicked;
|
||||
Button2.clicked += Button2_clicked;
|
||||
Button3.clicked += Button3_clicked;
|
||||
Button4.clicked += Button4_clicked;
|
||||
}
|
||||
private void Button1_clicked() {
|
||||
ModuleCore.ModuleScene.LoadSceneAsync(scene1);
|
||||
//ModuleCore.ModuleScene.LoadSceneAsync(scene1);
|
||||
}
|
||||
private void Button2_clicked() {
|
||||
ModuleCore.ModuleScene.LoadSceneAsync(scene2);
|
||||
//ModuleCore.ModuleScene.LoadSceneAsync(scene2);
|
||||
}
|
||||
private void Button3_clicked() {
|
||||
ModuleCore.ModuleScene.LoadSceneAsync(scene3);
|
||||
//ModuleCore.ModuleScene.LoadSceneAsync(scene3);
|
||||
}
|
||||
private void Button4_clicked() {
|
||||
ModuleCore.ModuleScene.LoadSceneAsync(returnScene);
|
||||
//ModuleCore.ModuleScene.LoadSceneAsync(returnScene);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ public class UIDeviceVideo : ModuleUIPanel<DataVideo> {
|
||||
private Button CloseButton => element.Q<Button>("Close");
|
||||
public override void Awake() {
|
||||
//初始化模块
|
||||
ModuleCore.VideoPanel = this;
|
||||
//ModuleCore.VideoPanel = this;
|
||||
InitElement();
|
||||
//加载视频媒体ui
|
||||
VisualElement media = element.Q<VisualElement>("MediaPlayer");
|
||||
@@ -20,7 +20,7 @@ public class UIDeviceVideo : ModuleUIPanel<DataVideo> {
|
||||
public override void Open(DataVideo data) {
|
||||
this.data = data;
|
||||
element.style.display = DisplayStyle.Flex;
|
||||
ModuleCore.ModuleVideo.SetValue(data);
|
||||
//ModuleCore.ModuleVideo.SetValue(data);
|
||||
mediaPlayer.Open();
|
||||
}
|
||||
public override void Close() {
|
||||
@@ -35,9 +35,9 @@ public class UIDeviceVideo : ModuleUIPanel<DataVideo> {
|
||||
/// <summary> 全屏播放功能 </summary>
|
||||
private void MediaPlayerFullScreen() {
|
||||
element.style.display = DisplayStyle.None;
|
||||
ModuleCore.FullScreenVideoPanel.Open(() => {
|
||||
mediaPlayer.Open();
|
||||
element.style.display = DisplayStyle.Flex;
|
||||
});
|
||||
//ModuleCore.FullScreenVideoPanel.Open(() => {
|
||||
// mediaPlayer.Open();
|
||||
// element.style.display = DisplayStyle.Flex;
|
||||
//});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public class UIDeviceVideoImage : ModuleUIPanel<DataVideoImage> {
|
||||
|
||||
public override void Awake() {
|
||||
//初始化模块
|
||||
ModuleCore.VideoImagePanel = this;
|
||||
//ModuleCore.VideoImagePanel = this;
|
||||
InitElement();
|
||||
//加载视频媒体ui
|
||||
VisualElement media = element.Q<VisualElement>("MediaPlayer");
|
||||
@@ -29,7 +29,7 @@ public class UIDeviceVideoImage : ModuleUIPanel<DataVideoImage> {
|
||||
public override void Open(DataVideoImage data) {
|
||||
this.data = data;
|
||||
element.style.display = DisplayStyle.Flex;
|
||||
ModuleCore.ModuleVideo.SetValue(data.dataVideo);
|
||||
//ModuleCore.ModuleVideo.SetValue(data.dataVideo);
|
||||
Image.style.backgroundImage = new StyleBackground(data.sprite);
|
||||
Button2_clicked();
|
||||
}
|
||||
@@ -45,10 +45,10 @@ public class UIDeviceVideoImage : ModuleUIPanel<DataVideoImage> {
|
||||
/// <summary> 全屏播放功能 </summary>
|
||||
private void MediaPlayerFullScreen() {
|
||||
element.style.display = DisplayStyle.None;
|
||||
ModuleCore.FullScreenVideoPanel.Open(() => {
|
||||
mediaPlayer.Open();
|
||||
element.style.display = DisplayStyle.Flex;
|
||||
});
|
||||
//ModuleCore.FullScreenVideoPanel.Open(() => {
|
||||
// mediaPlayer.Open();
|
||||
// element.style.display = DisplayStyle.Flex;
|
||||
//});
|
||||
}
|
||||
private void Button1_clicked() {
|
||||
mediaPlayer.Close();
|
||||
|
||||
@@ -8,7 +8,7 @@ public class UIFullScreenVideo : ModuleUIPanel<Action> {
|
||||
private Action callback;
|
||||
private MediaPlayer mediaPlayer;
|
||||
public override void Awake() {
|
||||
ModuleCore.FullScreenVideoPanel = this;
|
||||
//ModuleCore.FullScreenVideoPanel = this;
|
||||
InitElement();
|
||||
VisualElement media = element.Q<VisualElement>("MediaPlayer");
|
||||
mediaPlayer = new MediaPlayer(media, Close);
|
||||
|
||||
@@ -21,7 +21,7 @@ public class UILearningVideo : ModuleUIPanel<Action> {
|
||||
private Button CloseButton => element.Q<Button>("Close");
|
||||
public override void Awake() {
|
||||
//初始化模块
|
||||
ModuleCore.LearningVideoPanel = this;
|
||||
//ModuleCore.LearningVideoPanel = this;
|
||||
InitElement();
|
||||
//加载视频媒体ui
|
||||
VisualElement media = element.Q<VisualElement>("MediaPlayer");
|
||||
@@ -49,24 +49,24 @@ public class UILearningVideo : ModuleUIPanel<Action> {
|
||||
/// <summary> 全屏播放功能 </summary>
|
||||
private void MediaPlayerFullScreen() {
|
||||
element.style.display = DisplayStyle.None;
|
||||
ModuleCore.FullScreenVideoPanel.Open(() => {
|
||||
mediaPlayer.Open();
|
||||
element.style.display = DisplayStyle.Flex;
|
||||
});
|
||||
//ModuleCore.FullScreenVideoPanel.Open(() => {
|
||||
// mediaPlayer.Open();
|
||||
// element.style.display = DisplayStyle.Flex;
|
||||
//});
|
||||
}
|
||||
private void Button1_clicked() {
|
||||
DataVideoClip videoClip = new DataVideoClip(clip1);
|
||||
ModuleCore.ModuleVideo.SetValue(videoClip);
|
||||
//ModuleCore.ModuleVideo.SetValue(videoClip);
|
||||
mediaPlayer.Open();
|
||||
}
|
||||
private void Button2_clicked() {
|
||||
DataVideoClip videoClip = new DataVideoClip(clip2);
|
||||
ModuleCore.ModuleVideo.SetValue(videoClip);
|
||||
//ModuleCore.ModuleVideo.SetValue(videoClip);
|
||||
mediaPlayer.Open();
|
||||
}
|
||||
private void Button3_clicked() {
|
||||
DataVideoClip videoClip = new DataVideoClip(clip3);
|
||||
ModuleCore.ModuleVideo.SetValue(videoClip);
|
||||
//ModuleCore.ModuleVideo.SetValue(videoClip);
|
||||
mediaPlayer.Open();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5e34f7c1927a3940b874cf7357c05c6
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,111 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using MuHua;
|
||||
|
||||
public class PlateDesign : ModulePlateDesign {
|
||||
public Transform PlateParent;
|
||||
public Transform PlateTemplate;
|
||||
|
||||
private DataPlate dataPlate;
|
||||
|
||||
public override void AddData(DataPlate data) {
|
||||
PlateParent.Instantiate(PlateTemplate, data, true);
|
||||
}
|
||||
|
||||
#region 边缘点操作
|
||||
private PrefabPlateEdge edgePoint;
|
||||
public override bool IsValidEdgePoint => edgePoint != null;
|
||||
public override Vector3 EdgePointPosition => edgePoint.CurrentPosition;
|
||||
public override void SelectEdgePoint(Vector3 screenPosition) {
|
||||
edgePoint = RayFind<PrefabPlateEdge>(screenPosition, DefaultLayerMask);
|
||||
if (!IsValidEdgePoint) { return; }
|
||||
dataPlate = edgePoint.value;
|
||||
}
|
||||
public override void ChangeEdgePoint(Vector3 localPosition) {
|
||||
if (!IsValidEdgePoint) { return; }
|
||||
dataPlate.ChangeEdgePoint(edgePoint.index, localPosition);
|
||||
}
|
||||
public override void InsertEdgePoint(Vector3 screenPosition) {
|
||||
Vector3 position = ViewCamera.ScreenToWorldPosition(screenPosition);
|
||||
Vector3 worldPosition = position + ViewCamera.CameraWorldPosition;
|
||||
worldPosition.z = 0;
|
||||
edgePoint = Physics2DOverlapCircleAll<PrefabPlateEdge>(worldPosition, DefaultLayerMask);
|
||||
if (!IsValidEdgePoint) { return; }
|
||||
dataPlate = edgePoint.value;
|
||||
dataPlate?.InsertEdgePoint(edgePoint.index, position);
|
||||
}
|
||||
public override void ReleaseEdgePoint() {
|
||||
if (!IsValidEdgePoint) { return; }
|
||||
dataPlate.Compute();
|
||||
edgePoint = null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 设计点操作
|
||||
private PrefabDesignPoint designPoint;
|
||||
public override bool IsValidDesignPoint => designPoint != null;
|
||||
public override Vector3 DesignPointPosition => designPoint.Position;
|
||||
public override void SelectDesignPoint(Vector3 screenPosition) {
|
||||
designPoint = RayFind<PrefabDesignPoint>(screenPosition, DefaultLayerMask);
|
||||
if (!IsValidDesignPoint) { return; }
|
||||
dataPlate = designPoint.DataPlate;
|
||||
}
|
||||
public override void ChangeDesignPoint(Vector3 localPosition) {
|
||||
if (!IsValidDesignPoint) { return; }
|
||||
dataPlate.ChangeDesignPoint(designPoint.Index, localPosition);
|
||||
}
|
||||
public override void InsertDesignPoint(Vector3 screenPosition) {
|
||||
Vector3 position = ViewCamera.ScreenToWorldPosition(screenPosition);
|
||||
Vector3 worldPosition = position + ViewCamera.CameraWorldPosition;
|
||||
worldPosition.z = 0;
|
||||
designPoint = Physics2DOverlapCircleAll<PrefabDesignPoint>(worldPosition, DefaultLayerMask);
|
||||
if (!IsValidDesignPoint) { return; }
|
||||
dataPlate = designPoint.DataPlate;
|
||||
dataPlate?.InsertDesignPoint(designPoint.Index, position);
|
||||
}
|
||||
public override void ReleaseDesignPoint() {
|
||||
if (!IsValidDesignPoint) { return; }
|
||||
dataPlate.Compute();
|
||||
designPoint = null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 贝塞尔曲线操作
|
||||
private PrefabBezierPoint bezierPoint;
|
||||
public override bool IsValidBezierPoint => bezierPoint != null;
|
||||
public override Vector3 BezierPointPosition => bezierPoint.Position;
|
||||
public override void SelectBezierPoint(Vector3 screenPosition) {
|
||||
bezierPoint = RayFind<PrefabBezierPoint>(screenPosition, DefaultLayerMask);
|
||||
if (!IsValidBezierPoint) { return; }
|
||||
dataPlate = bezierPoint.DataPlate;
|
||||
}
|
||||
public override void ChangeBezierPoint(Vector3 localPosition) {
|
||||
if (!IsValidBezierPoint) { return; }
|
||||
bezierPoint.Change(localPosition);
|
||||
}
|
||||
public override void ReleaseBezierPoint() {
|
||||
if (!IsValidBezierPoint) { return; }
|
||||
dataPlate.Compute();
|
||||
bezierPoint = null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 检测方法
|
||||
private RaycastHit hitInfo;
|
||||
private readonly float CheckRange = 0.02f;
|
||||
private readonly LayerMask DefaultLayerMask = ~(1 << 0) | 1 << 0;
|
||||
/// <summary> 射线检测 </summary>
|
||||
private T RayFind<T>(Vector3 screenPosition, LayerMask layerMask) where T : Object {
|
||||
Ray ray = ViewCamera.ScreenPointToRay(screenPosition);
|
||||
Physics.Raycast(ray, out hitInfo, 200, layerMask);
|
||||
return hitInfo.transform?.GetComponent<T>();
|
||||
}
|
||||
/// <summary> 物理2D圆形检测 </summary>
|
||||
private T Physics2DOverlapCircleAll<T>(Vector3 worldPosition, LayerMask layerMask) where T : Object {
|
||||
Collider2D[] colliders = Physics2D.OverlapCircleAll(worldPosition, CheckRange, layerMask);
|
||||
if (colliders.Length == 0) { return null; }
|
||||
return colliders[0].GetComponentInParent<T>();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b896900f689abba438628c5bbef5125f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c944a47248a72ee4383dd37f9906753b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,24 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
public class UIPageGarmentSewing : ModuleUIPage {
|
||||
private TopMenu topMenu;
|
||||
private UIPlateDesign plateDesign;
|
||||
private UIPlateBaking plateBaking;
|
||||
private VisualElement TopMenuElement => Q<VisualElement>("TopMenu");
|
||||
private VisualElement PlateDesignElement => Q<VisualElement>("PlateDesign");
|
||||
private VisualElement PlateBakingElement => Q<VisualElement>("PlateBaking");
|
||||
protected override void Awake() {
|
||||
ModuleCore.CurrentPage = this;
|
||||
}
|
||||
private void Start() {
|
||||
topMenu = new TopMenu(TopMenuElement);
|
||||
plateDesign = new UIPlateDesign(PlateDesignElement);
|
||||
plateBaking = new UIPlateBaking(PlateBakingElement);
|
||||
|
||||
topMenu.ClickTopMenu1 = () => { };
|
||||
topMenu.ClickTopMenu2 = () => { ModuleCore.PresetsPlateWindow.Open(null); };
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d436e806ac6755d4fb29cdb0f7208615
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28c2a70ea090a674a9f12dd415abbec9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
public class UIWindowPresetsPlate : ModuleUIWindow<Action> {
|
||||
public VisualTreeAsset PresetsPlateUnitAsset;
|
||||
private UIPresetsPlate presetsPlate;
|
||||
private VisualElement element => ModuleUIPage.Q<VisualElement>("PresetsPlate");
|
||||
private ModuleAssets<DataPresetsPlate> PresetsPlateAssets => ModuleCore.PresetsPlateAssets;
|
||||
public override void Awake() {
|
||||
ModuleCore.PresetsPlateWindow = this;
|
||||
presetsPlate = new UIPresetsPlate(element);
|
||||
|
||||
presetsPlate.ClickClose = Close;
|
||||
}
|
||||
public override void Open(Action data) {
|
||||
element.style.display = DisplayStyle.Flex;
|
||||
presetsPlate.Clear();
|
||||
PresetsPlateAssets.ForEach(Create);
|
||||
}
|
||||
public override void Close() {
|
||||
presetsPlate.Clear();
|
||||
element.style.display = DisplayStyle.None;
|
||||
}
|
||||
private void Create(DataPresetsPlate data) {
|
||||
VisualElement temp = PresetsPlateUnitAsset.Instantiate();
|
||||
UIPresetsPlateUnit unit = new UIPresetsPlateUnit(temp, data);
|
||||
unit.Click = () => { CreateTemplate(data); };
|
||||
presetsPlate.Add(unit);
|
||||
}
|
||||
private void CreateTemplate(DataPresetsPlate data) {
|
||||
ModuleCore.PlateDesign.AddData(data.ToPlate());
|
||||
Close();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a930d912222858846a23606c170a59d8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8c1f6f992590ee740829401bdf9c7486
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,42 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary> 未初始化的视图相机模块 </summary>
|
||||
public class ViewCamera : ModuleViewCamera {
|
||||
public Camera viewCamera;
|
||||
public Transform viewSpace;
|
||||
|
||||
private RenderTexture renderTexture;
|
||||
|
||||
public override Vector3 Position { get => viewSpace.position; set => viewSpace.position = value; }
|
||||
public override Vector3 EulerAngles { get => viewSpace.eulerAngles; set => viewSpace.eulerAngles = value; }
|
||||
public override Vector3 LocalScale { get => viewSpace.localScale; set => viewSpace.localScale = value; }
|
||||
public override float OrthographicSize { get => viewCamera.orthographicSize; set => viewCamera.orthographicSize = value; }
|
||||
public override Vector3 CurrentViewSpaceCenter => viewSpace.localPosition * -1;
|
||||
public override Vector3 CameraWorldPosition => viewCamera.transform.position;
|
||||
public override RenderTexture RenderTexture => renderTexture;
|
||||
|
||||
protected override void Awake() {
|
||||
Debug.LogError("需要重写 ViewCamera 的 Awake 方法!");
|
||||
}
|
||||
public override void UpdateRenderTexture(int x, int y) {
|
||||
renderTexture = new RenderTexture(x, y, 0);
|
||||
viewCamera.targetTexture = renderTexture;
|
||||
}
|
||||
public override Vector2 ScreenToWorldPosition(Vector2 screenPosition) {
|
||||
return ScreenToViewPosition(screenPosition) * OrthographicSize;
|
||||
}
|
||||
public override Vector2 ScreenToViewPosition(Vector2 screenPosition) {
|
||||
float x = screenPosition.x / viewCamera.pixelWidth;
|
||||
float y = 1 - screenPosition.y / viewCamera.pixelHeight;
|
||||
Vector2 mouseRatio = new Vector2(x - 0.5f, y - 0.5f);
|
||||
float aspectRatio = (float)viewCamera.pixelWidth / viewCamera.pixelHeight;
|
||||
return new Vector2(mouseRatio.x * aspectRatio, mouseRatio.y) * 2;
|
||||
}
|
||||
public override Ray ScreenPointToRay(Vector2 screenPosition) {
|
||||
Vector3 mousePosition = ScreenToWorldPosition(screenPosition);
|
||||
Vector3 worldPosition = mousePosition + viewCamera.transform.position;
|
||||
return new Ray(worldPosition, viewCamera.transform.forward);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2c9c4560364683648a17a66d4b7999fa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ViewCameraPlateBaking : ViewCamera {
|
||||
protected override void Awake() {
|
||||
ModuleCore.PlateBakingViewCamera = this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9eaab06c8ab27c4b8bad8ce8e831751
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ViewCameraPlateDesign : ViewCamera {
|
||||
protected override void Awake() {
|
||||
ModuleCore.PlateDesignViewCamera = this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 97f4f71f456807b4d959311475ce9687
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9bb7586553812904481ba6646ef7a74b
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ViewInput : ModuleViewInput {
|
||||
protected ModuleViewInputUnit leftViewInputUnit;
|
||||
protected ModuleViewInputUnit rightViewInputUnit;
|
||||
protected ModuleViewInputUnit middleViewInputUnit;
|
||||
protected ModuleViewInputUnit scrollViewInputUnit;
|
||||
|
||||
public override event Action<Type> OnInputType;
|
||||
|
||||
protected override void Awake() { }
|
||||
|
||||
protected virtual void InputType(Type type) {
|
||||
OnInputType?.Invoke(type);
|
||||
}
|
||||
public override void SetPrimaryKeyInput<T>(T inputUnit) {
|
||||
leftViewInputUnit = inputUnit;
|
||||
InputType(inputUnit.GetType());
|
||||
}
|
||||
|
||||
public override void DownLeftMouse(DataMouseInput data) {
|
||||
leftViewInputUnit?.DownMouse(data);
|
||||
}
|
||||
public override void DragLeftMouse(DataMouseInput data) {
|
||||
leftViewInputUnit?.DragMouse(data);
|
||||
}
|
||||
public override void MoveLeftMouse(DataMouseInput data) {
|
||||
leftViewInputUnit?.MoveMouse(data);
|
||||
}
|
||||
public override void ReleaseLeftMouse(DataMouseInput data) {
|
||||
leftViewInputUnit?.ReleaseMouse(data);
|
||||
}
|
||||
|
||||
public override void DownRightMouse(DataMouseInput data) {
|
||||
rightViewInputUnit?.DownMouse(data);
|
||||
}
|
||||
public override void DragRightMouse(DataMouseInput data) {
|
||||
rightViewInputUnit?.DragMouse(data);
|
||||
}
|
||||
public override void MoveRightMouse(DataMouseInput data) {
|
||||
rightViewInputUnit?.MoveMouse(data);
|
||||
}
|
||||
public override void ReleaseRightMouse(DataMouseInput data) {
|
||||
rightViewInputUnit?.ReleaseMouse(data);
|
||||
}
|
||||
|
||||
public override void DownMiddleMouse(DataMouseInput data) {
|
||||
middleViewInputUnit?.DownMouse(data);
|
||||
}
|
||||
public override void DragMiddleMouse(DataMouseInput data) {
|
||||
middleViewInputUnit?.DragMouse(data);
|
||||
}
|
||||
public override void MoveMiddleMouse(DataMouseInput data) {
|
||||
middleViewInputUnit?.MoveMouse(data);
|
||||
}
|
||||
public override void ReleaseMiddleMouse(DataMouseInput data) {
|
||||
middleViewInputUnit?.ReleaseMouse(data);
|
||||
}
|
||||
|
||||
public override void ScrollWheel(DataMouseInput data) {
|
||||
scrollViewInputUnit?.ScrollWheel(data);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f85e6264d841c84aa13ce7250a2652a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ViewInputPlateBaking : ViewInput {
|
||||
protected override void Awake() {
|
||||
ModuleCore.PlateBakingViewInput = this;
|
||||
}
|
||||
private void Start() {
|
||||
leftViewInputUnit = new VIUCameraMobile(ModuleCore.PlateBakingViewCamera);
|
||||
rightViewInputUnit = new VIUCameraRotate(ModuleCore.PlateBakingViewCamera);
|
||||
scrollViewInputUnit = new VIUCameraScale(ModuleCore.PlateBakingViewCamera);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9f89f4c7ba43a19488889a65b7f6c328
|
||||
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 ViewInputPlateDesign : ViewInput {
|
||||
protected override void Awake() {
|
||||
ModuleCore.PlateDesignViewInput = this;
|
||||
}
|
||||
private void Start() {
|
||||
//leftViewInputUnit = new VIUEdgePointMobile(ModuleCore.PlateDesignViewCamera);
|
||||
//leftViewInputUnit = new VIUEdgePointAdd(ModuleCore.PlateDesignViewCamera);
|
||||
rightViewInputUnit = new VIUCameraMobile(ModuleCore.PlateDesignViewCamera);
|
||||
//rightViewInputUnit = new VIUEdgePointMobile(ModuleCore.PlateDesignViewCamera);
|
||||
scrollViewInputUnit = new VIUCameraScale(ModuleCore.PlateDesignViewCamera, VIUCameraScale.ScaleType.Orthographic);
|
||||
|
||||
//Debug.Log(leftViewInputUnit.GetType());
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user