From cb2634dc767342db88ea646042390623c3d2df81 Mon Sep 17 00:00:00 2001 From: Afeijia Date: Wed, 30 Aug 2023 17:16:38 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AB=98=E4=BA=AEbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GQ_TongXin/Assets/Materials/HighLight_VR.cs | 24 ++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/GQ_TongXin/Assets/Materials/HighLight_VR.cs b/GQ_TongXin/Assets/Materials/HighLight_VR.cs index ededb4518..9d723d4ba 100644 --- a/GQ_TongXin/Assets/Materials/HighLight_VR.cs +++ b/GQ_TongXin/Assets/Materials/HighLight_VR.cs @@ -10,6 +10,8 @@ public class HighLight_VR : MonoBehaviour [ContextMenu("Highlight")] public void Highlight() { + Init(); + wasHovering = isHovering; isHovering = true; @@ -69,20 +71,32 @@ public class HighLight_VR : MonoBehaviour } protected virtual bool ShouldIgnore(GameObject check) { + if (hideHighlight == null) return false; for (int ignoreIndex = 0; ignoreIndex < hideHighlight.Length; ignoreIndex++) { - if (check == hideHighlight[ignoreIndex]) + if (hideHighlight != null && check == hideHighlight[ignoreIndex]) return true; } return false; } + bool inited = false; + + private void Init() + { + if (!inited) + { + inited = true; + highlightMat = (Material)Resources.Load("SteamVR_HoverHighlight", typeof(Material)); + if (highlightMat == null) + Debug.LogError("[SteamVR Interaction] Hover Highlight Material is missing. Please create a material named 'SteamVR_HoverHighlight' and place it in a Resources folder", this); + + } + } + protected virtual void Start() { - highlightMat = (Material)Resources.Load("SteamVR_HoverHighlight", typeof(Material)); - if (highlightMat == null) - Debug.LogError("[SteamVR Interaction] Hover Highlight Material is missing. Please create a material named 'SteamVR_HoverHighlight' and place it in a Resources folder", this); - + Init(); } protected virtual void CreateHighlightRenderers()