From 0199ff16fb652b024357b7799d03f47efd2bc5bb Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Thu, 20 Mar 2025 15:33:31 +0800 Subject: [PATCH] =?UTF-8?q?VR=E5=85=BC=E5=AE=B9=E6=80=A7=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Art/UIPrefab/UIDeviceTip.prefab | 18 +++---- .../UIKit/Scripts/Resources/VRUIRoot.prefab | 50 ++++++++++++++++++- Assets/Scripts/Controller/DeviceController.cs | 36 ++++++++++++- Assets/Scripts/UI/UIDeviceTip.cs | 4 +- 4 files changed, 96 insertions(+), 12 deletions(-) diff --git a/Assets/Art/UIPrefab/UIDeviceTip.prefab b/Assets/Art/UIPrefab/UIDeviceTip.prefab index e77484bc..69091ab2 100644 --- a/Assets/Art/UIPrefab/UIDeviceTip.prefab +++ b/Assets/Art/UIPrefab/UIDeviceTip.prefab @@ -84,10 +84,10 @@ RectTransform: m_Children: [] m_Father: {fileID: 7903088767531138588} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 1} - m_AnchorMax: {x: 0, y: 1} - m_AnchoredPosition: {x: 35.93, y: -16.205} - m_SizeDelta: {x: 41.86, y: 22.41} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &4957094274820776498 CanvasRenderer: @@ -240,7 +240,7 @@ RectTransform: m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} m_AnchoredPosition: {x: 0, y: 44.3} - m_SizeDelta: {x: 71.86, y: 32.41} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0.5000002, y: 0.4999999} --- !u!222 &1036003715876543771 CanvasRenderer: @@ -336,7 +336,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!224 &3498217952045278011 RectTransform: m_ObjectHideFlags: 0 @@ -352,9 +352,9 @@ RectTransform: - {fileID: 7903088767531138588} m_Father: {fileID: 5742674533081898516} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: 2.22} + m_AnchorMin: {x: 0.5, y: 1} + m_AnchorMax: {x: 0.5, y: 1} + m_AnchoredPosition: {x: 0, y: -180} m_SizeDelta: {x: 5, y: 5} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &3053206168475133008 diff --git a/Assets/QFramework/Toolkits/UIKit/Scripts/Resources/VRUIRoot.prefab b/Assets/QFramework/Toolkits/UIKit/Scripts/Resources/VRUIRoot.prefab index 43361eab..b0a0c9ba 100644 --- a/Assets/QFramework/Toolkits/UIKit/Scripts/Resources/VRUIRoot.prefab +++ b/Assets/QFramework/Toolkits/UIKit/Scripts/Resources/VRUIRoot.prefab @@ -257,6 +257,53 @@ MonoBehaviour: m_EditorClassIdentifier: FlipDuration: 0.1 SnapDuration: 0.05 +--- !u!1 &1390393074831861131 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 6892530253346669644} + - component: {fileID: 288270640094573032} + m_Layer: 0 + m_Name: ZProvider + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &6892530253346669644 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1390393074831861131} + 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: 6541928711621635503} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &288270640094573032 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1390393074831861131} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ae9977e6c48cd7040b272527034d9de1, type: 3} + m_Name: + m_EditorClassIdentifier: + _displayReferenceProfile: 2 + _displayReferenceSize: {x: 0.521, y: 0.293} + _displayReferenceResolution: {x: 1920, y: 1080} --- !u!1 &2151028106637981052 GameObject: m_ObjectHideFlags: 0 @@ -436,6 +483,7 @@ Transform: - {fileID: 2220253086530989832} - {fileID: 8195748885121142673} - {fileID: 2551710545134193972} + - {fileID: 6892530253346669644} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &960705820696497904 @@ -1586,7 +1634,7 @@ MonoBehaviour: m_EditorClassIdentifier: EventCamera: {fileID: 263436429275714491} Visualization: {fileID: 6603607056250446267} - MaxHitDistance: 1.5 + MaxHitDistance: 5 MaxHitRadius: 0 IgnoreMask: serializedVersion: 2 diff --git a/Assets/Scripts/Controller/DeviceController.cs b/Assets/Scripts/Controller/DeviceController.cs index cc353a2e..f1fbe328 100644 --- a/Assets/Scripts/Controller/DeviceController.cs +++ b/Assets/Scripts/Controller/DeviceController.cs @@ -1,9 +1,11 @@ +using GCSeries.Core.Input; using HighlightPlus; using QFramework; using QFramework.Example; using System; using System.Collections; using System.Collections.Generic; +using Unity.Burst.CompilerServices; using UnityEngine; using UnityEngine.EventSystems; using XMLTool; @@ -25,6 +27,37 @@ public class DeviceController : MonoSingleton TypeEventSystem.Global.Register(OnStart).UnRegisterWhenGameObjectDestroyed(gameObject); TypeEventSystem.Global.Register(OnQuit).UnRegisterWhenGameObjectDestroyed(gameObject); +#if VR + UIRoot.Instance.transform.Find("ZStylus").GetComponent()?.OnObjectEntered.AddListener(OnObjEnter); + UIRoot.Instance.transform.Find("ZMouse").GetComponent()?.OnObjectEntered.AddListener(OnObjEnter); +#endif + } + + + private void OnObjEnter(ZPointer arg0, GameObject arg1) + { + var deviceItem = arg1.GetComponent(); + var uitip = UIKit.GetPanel(); + if (deviceItem != null && deviceItem.tipItem != null) + { + if (uitip != null) + { + UIKit.OpenPanelAsync(UILevel.PopUI).ToAction().Start(this, () => + { + }); + } + if (uitip != null) + { + uitip.Set(deviceItem.tipItem.label); + uitip.Active(true); + return; + } + } + else + { + uitip?.Active(false); + } + } private void OnQuit(OnModuleQuit quit) @@ -69,6 +102,7 @@ public class DeviceController : MonoSingleton private void Update() { +#if !VR var uitip = UIKit.GetPanel(); if (uitip != null) { @@ -90,7 +124,7 @@ public class DeviceController : MonoSingleton } } uitip?.Active(false); - +#endif } public DeviceItem GetDeviceItem(string name) { diff --git a/Assets/Scripts/UI/UIDeviceTip.cs b/Assets/Scripts/UI/UIDeviceTip.cs index 47b0496d..bdbad4ad 100644 --- a/Assets/Scripts/UI/UIDeviceTip.cs +++ b/Assets/Scripts/UI/UIDeviceTip.cs @@ -22,7 +22,8 @@ namespace QFramework.Example { } - void Update() +#if !VR + public void Update() { if (Point.gameObject.activeSelf) { @@ -30,6 +31,7 @@ namespace QFramework.Example } } +#endif public void Set(string txt) {