From d8b56b667aa5ab85cc9fd2bdbb17b8fc077daa7e Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Mon, 13 Jan 2025 11:24:03 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=A9=BA=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Controller/DeviceController.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/Controller/DeviceController.cs b/Assets/Scripts/Controller/DeviceController.cs index 1d9444a7..5b7b7195 100644 --- a/Assets/Scripts/Controller/DeviceController.cs +++ b/Assets/Scripts/Controller/DeviceController.cs @@ -41,8 +41,8 @@ public class DeviceController : MonoSingleton if (string.IsNullOrEmpty(device.Path) == false) { obj = Utility.FindObj(device.Path); - item = obj.GetOrAddComponent(); - item.Init(device); + item = obj?.GetOrAddComponent(); + item?.Init(device); } deviceDict.Add(device.Name, new DeviceData() { device = device, item = item }); } From 593fe9e0bf920bbebd86847ea8aeb38a17bc3212 Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Mon, 13 Jan 2025 11:55:37 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=9B=B8=E6=9C=BA?= =?UTF-8?q?=E8=B7=B3=E8=B7=83=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/FreeCameraController.cs | 36 ++++++++++++++++++-------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/Assets/Scripts/FreeCameraController.cs b/Assets/Scripts/FreeCameraController.cs index 89c40a15..d0072685 100644 --- a/Assets/Scripts/FreeCameraController.cs +++ b/Assets/Scripts/FreeCameraController.cs @@ -22,6 +22,7 @@ public class FreeCameraController : MonoBehaviour private float yRotation = 0.0f; public bool isMov = true; public bool isRot = true; + private void Awake() { instance = this; @@ -32,7 +33,7 @@ public class FreeCameraController : MonoBehaviour void Update() { - if (isMov == true) + if (isMov) { // ƶ float horizontal = Input.GetAxis("Horizontal") * moveSpeed * Time.deltaTime; @@ -58,7 +59,6 @@ public class FreeCameraController : MonoBehaviour { // ת - Vector3 mouseDelta = Input.mousePosition - lastMousePosition; // תֵ lastMousePosition = Input.mousePosition; @@ -68,8 +68,8 @@ public class FreeCameraController : MonoBehaviour // X תΧ xRotation = Mathf.Clamp(xRotation, -xRotationLimit, xRotationLimit); - //// Y תΧ - //if (minRotationLimitY!=-1&&maxRotationLimitY!=-1) + // Y תΧ + //if (minRotationLimitY != -1 && maxRotationLimitY != -1) //{ // yRotation = Mathf.Clamp(yRotation, minRotationLimitY, maxRotationLimitY); //} @@ -77,10 +77,6 @@ public class FreeCameraController : MonoBehaviour transform.rotation = Quaternion.Euler(xRotation, yRotation, 0); } } - - - - } // תָ @@ -102,9 +98,27 @@ public class FreeCameraController : MonoBehaviour Vector3 currentRotation = transform.eulerAngles; xRotation = currentRotation.x; yRotation = currentRotation.y; - transform.eulerAngles = currentRotation; - //minRotationLimitY = currentRotation.y - yRotationLimit / 2; - //maxRotationLimitY = currentRotation.y + yRotationLimit / 2; + + // һ xRotation yRotation + if (xRotation > 180f) + { + xRotation -= 360f; + } + else if (xRotation < -180f) + { + xRotation += 360f; + } + + if (yRotation > 180f) + { + yRotation -= 360f; + } + else if (yRotation < -180f) + { + yRotation += 360f; + } + + transform.eulerAngles = new Vector3(xRotation, yRotation, 0); } public void SetLock(bool isMov, bool isRot) From a36a2c16af59f6734127f072547ef99a91a0385f Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Mon, 13 Jan 2025 14:05:32 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=89=A9=E5=B1=95timeline=20=E6=96=B0?= =?UTF-8?q?=E5=A2=9Epoint3D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Resources/PointQuestion.meta | 8 ++ Assets/Resources/PointQuestion/Point3D.prefab | 108 ++++++++++++++++++ .../PointQuestion/Point3D.prefab.meta | 7 ++ Assets/Scripts/Actions/ActionHelper.cs | 3 +- .../Scripts/Actions/Point3DQuestionAction.cs | 77 +++++++++++++ .../Actions/Point3DQuestionAction.cs.meta | 11 ++ Assets/Scripts/Actions/TimeLineAction.cs | 2 + Assets/Scripts/Event/Events.cs | 5 + Assets/Scripts/Item/Point3DItem.cs | 54 +++++++++ Assets/Scripts/Item/Point3DItem.cs.meta | 11 ++ Assets/Scripts/Xml/XmlParser.cs | 33 ++++++ 11 files changed, 318 insertions(+), 1 deletion(-) create mode 100644 Assets/Resources/PointQuestion.meta create mode 100644 Assets/Resources/PointQuestion/Point3D.prefab create mode 100644 Assets/Resources/PointQuestion/Point3D.prefab.meta create mode 100644 Assets/Scripts/Actions/Point3DQuestionAction.cs create mode 100644 Assets/Scripts/Actions/Point3DQuestionAction.cs.meta create mode 100644 Assets/Scripts/Item/Point3DItem.cs create mode 100644 Assets/Scripts/Item/Point3DItem.cs.meta diff --git a/Assets/Resources/PointQuestion.meta b/Assets/Resources/PointQuestion.meta new file mode 100644 index 00000000..0393ff44 --- /dev/null +++ b/Assets/Resources/PointQuestion.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a3acec8ac3afd414fa0a2be823f49a24 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/PointQuestion/Point3D.prefab b/Assets/Resources/PointQuestion/Point3D.prefab new file mode 100644 index 00000000..182e0947 --- /dev/null +++ b/Assets/Resources/PointQuestion/Point3D.prefab @@ -0,0 +1,108 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &1284784233713093028 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8501359242958135856} + - component: {fileID: 5342714518506889861} + - component: {fileID: 1233232777813664732} + m_Layer: 0 + m_Name: Point3D + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &8501359242958135856 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1284784233713093028} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!212 &5342714518506889861 +SpriteRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1284784233713093028} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_StaticShadowCaster: 0 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 0 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 21300000, guid: 700820383005de14fba6008141269066, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 0.74, y: 0.74} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 + m_SpriteSortPoint: 0 +--- !u!65 &1233232777813664732 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1284784233713093028} + m_Material: {fileID: 0} + m_IncludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_ExcludeLayers: + serializedVersion: 2 + m_Bits: 0 + m_LayerOverridePriority: 0 + m_IsTrigger: 0 + m_ProvidesContacts: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Size: {x: 0.74, y: 0.74, z: 0.01} + m_Center: {x: 0, y: 0, z: 0} diff --git a/Assets/Resources/PointQuestion/Point3D.prefab.meta b/Assets/Resources/PointQuestion/Point3D.prefab.meta new file mode 100644 index 00000000..1fd4a871 --- /dev/null +++ b/Assets/Resources/PointQuestion/Point3D.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: fb7ff50a33ffd164e86af9f12182291b +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Actions/ActionHelper.cs b/Assets/Scripts/Actions/ActionHelper.cs index b48e6ff9..77822f6e 100644 --- a/Assets/Scripts/Actions/ActionHelper.cs +++ b/Assets/Scripts/Actions/ActionHelper.cs @@ -117,9 +117,10 @@ public class ActionHelper } case "PointQuestion": return PointQuestionAction.Allocate(act.Value); + case "Point3DQuestion": + return Point3DQuestionAction.Allocate(act.Value); case "TextQuestion": { - var strAction = (XMLTool.DictionaryAction)act; return TextQuestionAction.Allocate(strAction.args); } diff --git a/Assets/Scripts/Actions/Point3DQuestionAction.cs b/Assets/Scripts/Actions/Point3DQuestionAction.cs new file mode 100644 index 00000000..9a8b8e2a --- /dev/null +++ b/Assets/Scripts/Actions/Point3DQuestionAction.cs @@ -0,0 +1,77 @@ +using QFramework.Example; +using System; +using System.Collections.Generic; +using UnityEngine; +using XMLTool; + +namespace QFramework +{ + internal class Point3DQuestionAction : IAction + { + public System.Action OnFinished { get; set; } + + + private Point3DQuestionAction() + { + } + + private static readonly SimpleObjectPool mPool = + new SimpleObjectPool(() => new Point3DQuestionAction(), null, 10); + List datas; + public static Point3DQuestionAction Allocate(List datas, System.Action OnFinished = null) + { + var retNode = mPool.Allocate(); + retNode.ActionID = ActionKit.ID_GENERATOR++; + retNode.Deinited = false; + retNode.Reset(); + retNode.OnFinished = OnFinished; + retNode.datas = datas; + return retNode; + } + + + public ulong ActionID { get; set; } + public ActionStatus Status { get; set; } + + public void OnStart() + { + + foreach (var item in datas) + { + GameObject obj = GameObject.Instantiate(Resources.Load("PointQuestion/Point3D")) as GameObject; + obj.GetOrAddComponent().Init(item); + } + + } + + public void OnExecute(float dt) + { + } + + public void OnFinish() + { + } + + public void Reset() + { + Status = ActionStatus.NotStart; + Paused = false; + } + + public bool Paused { get; set; } + + public void Deinit() + { + if (!Deinited) + { + OnFinished = null; + Deinited = true; + mPool.Recycle(this); + } + } + + public bool Deinited { get; set; } + } + + +} diff --git a/Assets/Scripts/Actions/Point3DQuestionAction.cs.meta b/Assets/Scripts/Actions/Point3DQuestionAction.cs.meta new file mode 100644 index 00000000..0336c133 --- /dev/null +++ b/Assets/Scripts/Actions/Point3DQuestionAction.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5244807ebb490c644b600c03c490c8a5 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Actions/TimeLineAction.cs b/Assets/Scripts/Actions/TimeLineAction.cs index 89268a34..114b435c 100644 --- a/Assets/Scripts/Actions/TimeLineAction.cs +++ b/Assets/Scripts/Actions/TimeLineAction.cs @@ -49,6 +49,8 @@ public class TimeLineAction : IAction { if (!Deinited) { + play?.Stop(); + play = null; Deinited = true; mPool.Recycle(this); } diff --git a/Assets/Scripts/Event/Events.cs b/Assets/Scripts/Event/Events.cs index cd91424b..b495c532 100644 --- a/Assets/Scripts/Event/Events.cs +++ b/Assets/Scripts/Event/Events.cs @@ -32,4 +32,9 @@ public struct OnLoadingShow public struct OnLoadingHide { +} + +public struct OnPoint3DQuestionDestroy +{ + } \ No newline at end of file diff --git a/Assets/Scripts/Item/Point3DItem.cs b/Assets/Scripts/Item/Point3DItem.cs new file mode 100644 index 00000000..e0ec7698 --- /dev/null +++ b/Assets/Scripts/Item/Point3DItem.cs @@ -0,0 +1,54 @@ +using QFramework; +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using XMLTool; +using static UnityEditor.Progress; + +public class Point3DItem : MonoBehaviour +{ + Point3DQuestion.Data data; + + [SerializeField] + private float rotSpeed = 180.0f; + public void Init(Point3DQuestion.Data data) + { + this.data = data; + if (string.IsNullOrEmpty(data.deviceName)) + { + gameObject.transform.position = data.pos; + gameObject.transform.eulerAngles = data.rotate; + gameObject.transform.localScale = data.scale; + } + else + { + GameObject device = DeviceController.Instance.GetDeviceObj(data.deviceName); + gameObject.transform.parent = device.transform; + } + rotSpeed = data.rotateSpeed; + TypeEventSystem.Global.Register(OnObjDestroy).UnRegisterWhenGameObjectDestroyed(gameObject); + + } + + private void OnObjDestroy(OnPoint3DQuestionDestroy destroy) + { + GameObject.Destroy(gameObject); + } + + private void OnMouseUpAsButton() + { + if (string.IsNullOrEmpty(data.clickEvent) == false) + { + StringEventSystem.Global.Send(data.clickEvent); + } + TypeEventSystem.Global.Send(); + } + + private void OnMouseOver() + { + transform.Rotate(Vector3.forward * Time.deltaTime * rotSpeed); + } + + +} diff --git a/Assets/Scripts/Item/Point3DItem.cs.meta b/Assets/Scripts/Item/Point3DItem.cs.meta new file mode 100644 index 00000000..801d3138 --- /dev/null +++ b/Assets/Scripts/Item/Point3DItem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 41e7cf2ae7cf2f442b55807a5d42ee94 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Xml/XmlParser.cs b/Assets/Scripts/Xml/XmlParser.cs index 20dcf3f9..7bdf0a90 100644 --- a/Assets/Scripts/Xml/XmlParser.cs +++ b/Assets/Scripts/Xml/XmlParser.cs @@ -3,6 +3,7 @@ using QFramework; using System.Collections.Generic; using System.Linq; using System.Xml.Linq; +using UnityEngine; namespace XMLTool { public class AppData @@ -74,6 +75,21 @@ namespace XMLTool { } + public class Point3DQuestion : Action + { + public class Data + { + public string name; + public string deviceName; + public Vector3 pos; + public Vector3 rotate; + public Vector3 scale; + public float rotateSpeed; + public string clickEvent; + } + public List datas = new List(); + } + public class Condition : ActionItem { } @@ -1068,6 +1084,23 @@ namespace XMLTool newAction = act; } break; + case "Point3DQuestion": + { + var act = new Point3DQuestion(); + var datas = action.Elements("Data"); + foreach (var item in datas) + { + Point3DQuestion.Data data = new Point3DQuestion.Data(); + data.name = item.Attribute("name")?.Value; + data.pos = Utility.GetVector3FromStrArray(item.Attribute("position")?.Value); + data.rotate = Utility.GetVector3FromStrArray(item.Attribute("rotate")?.Value); + data.scale = Utility.GetVector3FromStrArray(item.Attribute("scale")?.Value); + data.clickEvent = item.Attribute("clickEvent")?.Value; + act.datas.Add(data); + } + newAction = act; + } + break; default: newAction = new Action(); break;