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;