From 5105a9b9ab237db342f484a4c27315117fdaf5d9 Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Mon, 31 Mar 2025 16:07:26 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8DVR?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Art/UIPrefab/UITipWindow.prefab | 6 +- .../UIKit/Scripts/Resources/VRUIRoot.prefab | 328 +----------------- .../Scripts/Conditions/ObjClickCondition.cs | 29 +- Assets/Scripts/Item/DeviceItem.cs | 15 +- Assets/Scripts/Item/Point3DItem.cs | 47 +++ Assets/Scripts/UI/UIRightTop.cs | 2 +- Assets/Scripts/VR.meta | 8 + Assets/Scripts/VR/StylusVibration.cs | 111 ++++++ Assets/Scripts/VR/StylusVibration.cs.meta | 11 + 9 files changed, 226 insertions(+), 331 deletions(-) create mode 100644 Assets/Scripts/VR.meta create mode 100644 Assets/Scripts/VR/StylusVibration.cs create mode 100644 Assets/Scripts/VR/StylusVibration.cs.meta diff --git a/Assets/Art/UIPrefab/UITipWindow.prefab b/Assets/Art/UIPrefab/UITipWindow.prefab index ada0c7aa..0aecb229 100644 --- a/Assets/Art/UIPrefab/UITipWindow.prefab +++ b/Assets/Art/UIPrefab/UITipWindow.prefab @@ -136,7 +136,7 @@ MonoBehaviour: m_EditorClassIdentifier: m_Material: {fileID: 0} m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 + m_RaycastTarget: 0 m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} m_Maskable: 1 m_OnCullStateChanged: @@ -495,7 +495,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: MarkType: 0 - CustomComponentName: + CustomComponentName: Label CustomComment: mComponentName: TMPro.TextMeshProUGUI --- !u!1 &8134342667276409362 @@ -834,6 +834,6 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: MarkType: 0 - CustomComponentName: + CustomComponentName: BtnPrefab CustomComment: mComponentName: UnityEngine.UI.Button diff --git a/Assets/QFramework/Toolkits/UIKit/Scripts/Resources/VRUIRoot.prefab b/Assets/QFramework/Toolkits/UIKit/Scripts/Resources/VRUIRoot.prefab index 7fc3f886..f9dc78d8 100644 --- a/Assets/QFramework/Toolkits/UIKit/Scripts/Resources/VRUIRoot.prefab +++ b/Assets/QFramework/Toolkits/UIKit/Scripts/Resources/VRUIRoot.prefab @@ -123,8 +123,8 @@ Transform: m_GameObject: {fileID: 598348144801550191} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 2.1975, z: 0} - m_LocalScale: {x: 15, y: 15, z: 15} + m_LocalPosition: {x: 0, y: 0.1465, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: - {fileID: 5974269590546671381} @@ -144,7 +144,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: Frame: {fileID: 6717849271440217812} - ViewerScale: 15 + ViewerScale: 1 --- !u!1 &765259898297824089 GameObject: m_ObjectHideFlags: 0 @@ -174,7 +174,7 @@ Transform: serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} - m_LocalScale: {x: 15, y: 15, z: 15} + m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: - {fileID: 964729101505013327} @@ -192,7 +192,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: b20817e9db276aa4182f6e0885aa2ddf, type: 3} m_Name: m_EditorClassIdentifier: - ViewerScale: 15 + ViewerScale: 1 --- !u!114 &2720570802681005941 MonoBehaviour: m_ObjectHideFlags: 0 @@ -634,7 +634,7 @@ Transform: m_GameObject: {fileID: 3400309332038407868} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0.000000059604645} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -1007,7 +1007,6 @@ RectTransform: - {fileID: 4067008720307835646} - {fileID: 5346698416423119099} - {fileID: 6454445510295011543} - - {fileID: 2655199300068705655} m_Father: {fileID: 4955625632054724442} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0.5, y: 0.5} @@ -1129,7 +1128,7 @@ Transform: m_GameObject: {fileID: 4951725383111470759} serializedVersion: 2 m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 0, z: -0.000000059604645} + m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] @@ -1678,316 +1677,3 @@ MonoBehaviour: OnButtonReleased: m_PersistentCalls: m_Calls: [] ---- !u!1001 &2655199300079889975 -PrefabInstance: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - serializedVersion: 3 - m_TransformParent: {fileID: 7801786202371978394} - m_Modifications: - - target: {fileID: 132536, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_Name - value: Debug - objectReference: {fileID: 0} - - target: {fileID: 11414302, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_Size - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 11414302, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_Value - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 11440770, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_PresetInfoIsWorld - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 22400762, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchoredPosition.y - value: -0.000030517578 - objectReference: {fileID: 0} - - target: {fileID: 22426080, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchorMax.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22426080, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchorMax.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22426080, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22428984, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchorMax.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22428984, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22428984, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22428984, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_SizeDelta.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22428984, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22428984, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchoredPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22455554, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchorMax.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22455554, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22455554, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22455554, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_SizeDelta.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22455554, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22455554, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchoredPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22457152, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_Pivot.x - value: 0.5 - objectReference: {fileID: 0} - - target: {fileID: 22457152, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_Pivot.y - value: 0.5 - objectReference: {fileID: 0} - - target: {fileID: 22457152, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchorMax.x - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 22457152, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchorMax.y - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 22457152, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchorMin.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22457152, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22457152, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22457152, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_SizeDelta.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22457152, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_LocalScale.x - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 22457152, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_LocalScale.y - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 22457152, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_LocalScale.z - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 22457152, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_LocalPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22457152, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_LocalPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22457152, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_LocalPosition.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22457152, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 22457152, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_LocalRotation.x - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 22457152, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_LocalRotation.y - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 22457152, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_LocalRotation.z - value: -0 - objectReference: {fileID: 0} - - target: {fileID: 22457152, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22457152, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchoredPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22457152, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_LocalEulerAnglesHint.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22457152, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_LocalEulerAnglesHint.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22457152, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_LocalEulerAnglesHint.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22468896, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchorMax.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22468896, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22468896, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22468896, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_SizeDelta.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22468896, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22468896, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchoredPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22488670, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchorMax.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22488670, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22488670, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22488670, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_SizeDelta.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22488670, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22488670, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchoredPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22495692, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchorMax.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22495692, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22495692, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22495692, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_SizeDelta.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22495692, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 22495692, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchoredPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 224619367409363176, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchorMax.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 224619367409363176, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 224619367409363176, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 224619367409363176, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_SizeDelta.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 224619367409363176, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 224619367409363176, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchoredPosition.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 224856348943071238, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchorMax.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 224856348943071238, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchorMin.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 224856348943071238, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_SizeDelta.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 224856348943071238, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_SizeDelta.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 224856348943071238, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchoredPosition.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 224856348943071238, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - propertyPath: m_AnchoredPosition.y - value: 0 - objectReference: {fileID: 0} - m_RemovedComponents: - - {fileID: 11490438, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - - {fileID: 11440770, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - - {fileID: 22331464, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - m_RemovedGameObjects: [] - m_AddedGameObjects: [] - m_AddedComponents: [] - m_SourcePrefab: {fileID: 100100000, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} ---- !u!224 &2655199300068705655 stripped -RectTransform: - m_CorrespondingSourceObject: {fileID: 22457152, guid: 67117722a812a2e46ab8cb8eafbf5f5e, type: 3} - m_PrefabInstance: {fileID: 2655199300079889975} - m_PrefabAsset: {fileID: 0} diff --git a/Assets/Scripts/Conditions/ObjClickCondition.cs b/Assets/Scripts/Conditions/ObjClickCondition.cs index cd0c2e89..9ff00507 100644 --- a/Assets/Scripts/Conditions/ObjClickCondition.cs +++ b/Assets/Scripts/Conditions/ObjClickCondition.cs @@ -19,6 +19,7 @@ namespace QFramework string deviceName; bool isRight; + bool isClick = false; public static ObjClickCondition Allocate(string path, Dictionary datas) { var conditionAction = mSimpleObjectPool.Allocate(); @@ -32,6 +33,7 @@ namespace QFramework { bool.TryParse(datas["isRight"], out conditionAction.isRight); } + conditionAction.isClick = false; return conditionAction; } public bool Check() @@ -73,7 +75,7 @@ namespace QFramework } #endif - return false; + return isClick; } public bool Paused { get; set; } public bool Deinited { get; set; } @@ -89,12 +91,25 @@ namespace QFramework #if VR public void OnClick(ZPointer pointer, int index, GameObject obj) { - if (this.obj != null && obj == this.obj) + if (isRight) { - this.Finish(); - UIRoot.Instance.transform.Find("ZMouse").GetComponent().OnClick.RemoveListener(OnClick); - UIRoot.Instance.transform.Find("ZStylus").GetComponent().OnClick.RemoveListener(OnClick); + if (this.obj != null && obj == this.obj) + { + isClick = true; + } } + else + { + if (this.obj != null) + { + var item = obj.GetComponent(); + if (item != null && obj != this.obj) + { + isClick = true; + } + } + } + } #endif @@ -118,6 +133,10 @@ namespace QFramework obj = null; path = null; mSimpleObjectPool.Recycle(this); +#if VR + UIRoot.Instance.transform.Find("ZMouse").GetComponent().OnClick.RemoveListener(OnClick); + UIRoot.Instance.transform.Find("ZStylus").GetComponent().OnClick.RemoveListener(OnClick); +#endif } } diff --git a/Assets/Scripts/Item/DeviceItem.cs b/Assets/Scripts/Item/DeviceItem.cs index dda21e49..4a352cfd 100644 --- a/Assets/Scripts/Item/DeviceItem.cs +++ b/Assets/Scripts/Item/DeviceItem.cs @@ -24,6 +24,7 @@ public class DeviceItem : MonoBehaviour effect.outlineColor = Utility.ToColor(device.HighColor); StringEventSystem.Global.Register(Global.HighLightTrigger, OnHighLightTriggerEvent); TypeEventSystem.Global.Register(OnStepChanged); + TypeEventSystem.Global.Register(OnModuleQuitEvent); #if VR effect.constantWidth = false; @@ -55,11 +56,14 @@ public class DeviceItem : MonoBehaviour UIRoot.Instance.transform.Find("ZMouse").GetComponent().OnClick.AddListener(OnClick); UIRoot.Instance.transform.Find("ZStylus").GetComponent().OnClick.AddListener(OnClick); - gameObject.GetOrAddComponent(); + //gameObject.GetOrAddComponent(); + gameObject.GetOrAddComponent(); #endif } + + #if VR private void OnClick(ZPointer arg0, int arg1, GameObject arg2) @@ -110,6 +114,14 @@ public class DeviceItem : MonoBehaviour #endif private void OnStepChanged(StepStatusOnChange change) + { + CloseHighLight(); + } + private void OnModuleQuitEvent(OnModuleQuit quit) + { + CloseHighLight(); + } + public void CloseHighLight() { var effect = gameObject.GetComponent(); if (effect != null) @@ -124,6 +136,7 @@ public class DeviceItem : MonoBehaviour tipItem = null; StringEventSystem.Global.UnRegister(Global.HighLightTrigger, OnHighLightTriggerEvent); TypeEventSystem.Global.UnRegister(OnStepChanged); + TypeEventSystem.Global.UnRegister(OnModuleQuitEvent); } private void OnHighLightTriggerEvent(string[] obj) diff --git a/Assets/Scripts/Item/Point3DItem.cs b/Assets/Scripts/Item/Point3DItem.cs index 8acfd894..d0eb9353 100644 --- a/Assets/Scripts/Item/Point3DItem.cs +++ b/Assets/Scripts/Item/Point3DItem.cs @@ -1,3 +1,4 @@ +using GCSeries.Core.Input; using QFramework; using System; using System.Collections; @@ -40,8 +41,54 @@ public class Point3DItem : MonoBehaviour TypeEventSystem.Global.Register(OnObjDestroy); TypeEventSystem.Global.Register(OnStepChanged); + +#if VR + UIRoot.Instance.transform.Find("ZStylus").GetComponent().OnObjectEntered.AddListener(OnObjEnter); + UIRoot.Instance.transform.Find("ZStylus").GetComponent().OnObjectExited.AddListener(OnObjExit); + UIRoot.Instance.transform.Find("ZStylus").GetComponent().OnClick.AddListener(OnClick); +#endif } +#if VR + private void OnClick(ZPointer arg0, int arg1, GameObject arg2) + { + if (gameObject == arg2) + { + if (string.IsNullOrEmpty(data.clickEvent) == false) + { + StringEventSystem.Global.Send(data.clickEvent); + } + TypeEventSystem.Global.Send(); + } + } + + private void OnObjExit(ZPointer arg0, GameObject arg1) + { + if (gameObject == arg1) + { + isEnter = false; + } + + } + + private void OnObjEnter(ZPointer arg0, GameObject arg1) + { + if (gameObject == arg1) + { + isEnter = true; + } + } + + bool isEnter = false; + private void Update() + { + if (isEnter) + { + transform.Rotate(Vector3.forward * Time.deltaTime * rotSpeed); + } + } +#endif + private void OnStepChanged(StepStatusOnChange change) { OnObjDestroy(default); diff --git a/Assets/Scripts/UI/UIRightTop.cs b/Assets/Scripts/UI/UIRightTop.cs index ee4e1807..8e7c279d 100644 --- a/Assets/Scripts/UI/UIRightTop.cs +++ b/Assets/Scripts/UI/UIRightTop.cs @@ -46,7 +46,7 @@ namespace QFramework.Example UITipWindowData data = new UITipWindowData(); data.txt = "Ƿر"; - data.btns.Add(new UITipWindowData.ItemData() { txt = "", OnClick = () => Application.Quit() }); + data.btns.Add(new UITipWindowData.ItemData() { txt = "", OnClick = () => { Application.Quit(); } }); data.btns.Add(new UITipWindowData.ItemData() { txt = "" }); UIKit.OpenPanelAsync(uiData: data, canvasLevel: UILevel.PopUI).ToAction().StartGlobal(); } diff --git a/Assets/Scripts/VR.meta b/Assets/Scripts/VR.meta new file mode 100644 index 00000000..8694c18b --- /dev/null +++ b/Assets/Scripts/VR.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a7c1e718f16cc7e41a8325205bafa695 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/VR/StylusVibration.cs b/Assets/Scripts/VR/StylusVibration.cs new file mode 100644 index 00000000..e890ad59 --- /dev/null +++ b/Assets/Scripts/VR/StylusVibration.cs @@ -0,0 +1,111 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2007-2020 , Inc. All Rights Reserved. +// +//////////////////////////////////////////////////////////////////////////////// + +using UnityEngine; +using UnityEngine.EventSystems; + +using GCSeries.Core.Sdk; +using GCSeries.Core; + +/// +/// 未来立体 笔震动脚本 +/// +public class StylusVibration : MonoBehaviour, + IPointerEnterHandler, IPointerExitHandler +{ + //////////////////////////////////////////////////////////////////////// + // Inspector Fields + //////////////////////////////////////////////////////////////////////// + + public VibrationTypeEnum VibrationType; + public float VibrationIntensity; + + //////////////////////////////////////////////////////////////////////// + // Enumerators + //////////////////////////////////////////////////////////////////////// + + public enum VibrationTypeEnum + { + Constant, + FastPulse, + MediumPulse, + SlowPulse + } + + //////////////////////////////////////////////////////////////////////// + // MonoBehaviour Callbacks + //////////////////////////////////////////////////////////////////////// + + private void Start() + { + if (ZProvider.IsInitialized) + { + this._stylusTarget = ZProvider.StylusTarget; + this._stylusTarget.IsVibrationEnabled = true; + } + else + { + Debug.LogWarning("ZProvider can not initialize.\n Stylus" + + "vibration and LED light feedback will not be experienced."); + + Destroy(this); + } + } + + //////////////////////////////////////////////////////////////////////// + // Public Methods + //////////////////////////////////////////////////////////////////////// + + public void OnPointerEnter(PointerEventData eventData) + { + this.Vibrate(); + } + + public void OnPointerExit(PointerEventData eventData) + { + this._stylusTarget.StopVibration(); + } + + //////////////////////////////////////////////////////////////////////// + // Private Methods + //////////////////////////////////////////////////////////////////////// + + private void Vibrate() + { + switch (this.VibrationType) + { + case VibrationTypeEnum.Constant: + this._stylusTarget.StartVibration( + 1.0f, 0.0f, 100, this.VibrationIntensity); + break; + + case VibrationTypeEnum.FastPulse: + this._stylusTarget.StartVibration( + 0.1f, 0.1f, 100, this.VibrationIntensity); + break; + + case VibrationTypeEnum.MediumPulse: + this._stylusTarget.StartVibration( + 0.3f, 0.3f, 100, this.VibrationIntensity); + break; + + case VibrationTypeEnum.SlowPulse: + this._stylusTarget.StartVibration( + 0.6f, 0.6f, 100, this.VibrationIntensity); + break; + + default: + break; + } + } + + //////////////////////////////////////////////////////////////////////// + // Private Members + //////////////////////////////////////////////////////////////////////// + + private ZTarget _stylusTarget; +} + diff --git a/Assets/Scripts/VR/StylusVibration.cs.meta b/Assets/Scripts/VR/StylusVibration.cs.meta new file mode 100644 index 00000000..30e7f2d5 --- /dev/null +++ b/Assets/Scripts/VR/StylusVibration.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 096518624f225c648a0cf58d85666b9c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: