// // /*=============================================================================== // // Copyright (C) 2025 PhantomsXR Ltd. All Rights Reserved. // // // // This file is part of the Phantom.XRMOD.QuestModule.Runtime. // // // // The UnityXR-MODLibTest cannot be copied, distributed, or made available to // // third-parties for commercial purposes without written permission of PhantomsXR Ltd. // // // // Contact nswell@phantomsxr.com for licensing requests. // // ===============================================================================*/ using System; using System.Collections.Generic; using Phantom.XRMOD.XRMODUtilites.Runtime; using UnityEngine; using UnityEngine.Serialization; namespace Phantom.XRMOD.QuestModule.Runtime { /// /// Represents a group of visualizers for XR controllers on a specific platform. /// [System.Serializable] public class XRControllerVisualizerGroup { /// /// Name of the visualizer group. /// public string Name; /// /// The platform type this group belongs to. /// public PlatformType PlatformType; /// /// GameObject for the Left Controller visualizer. /// public GameObject LeftXRController; /// /// GameObject for the Right Controller visualizer. /// public GameObject RightXRController; /// /// Initializes a new instance of the class and disables visualizers by default. /// public XRControllerVisualizerGroup() { Disabled(); } /// /// Activates the visualizers for both controllers. /// public void Enabled() { if (LeftXRController) LeftXRController.SetActive(true); if (RightXRController) RightXRController.SetActive(true); } /// /// Deactivates the visualizers for both controllers. /// public void Disabled() { if (LeftXRController) LeftXRController.SetActive(false); if (RightXRController) RightXRController.SetActive(false); } } /// /// Manages the activation of controller visualizers based on the current platform. /// public class XRControllerVisualizerManager : MonoBehaviour { [SerializeField] private List xrControllerVisualizerGroups = new(); /// /// Unity Start lifecycle method. /// /// Disables all groups initially, then enables the group matching the current Quest platform. /// /// private void Start() { foreach (XRControllerVisualizerGroup tmp_Group in xrControllerVisualizerGroups) { tmp_Group.Disabled(); } #if !UNITY_EDITOR var tmp_QuestPlatform = RuntimePlatformHelper.GetQuestModel(); var tmp_XRControllerVisualizerGroup = xrControllerVisualizerGroups.Find(_controller => _controller.PlatformType == tmp_QuestPlatform); if (tmp_XRControllerVisualizerGroup != null) tmp_XRControllerVisualizerGroup.Enabled(); #else var tmp_XRControllerVisualizerGroup = xrControllerVisualizerGroups.Find(_controller => _controller.PlatformType == PlatformType.Quest3); if (tmp_XRControllerVisualizerGroup != null) tmp_XRControllerVisualizerGroup.Enabled(); #endif } } }