using System; using System.IO; using System.Linq; using System.Threading; using System.Collections; using System.Collections.Generic; using SimpleJSON; using UnityEngine; using UnityEngine.UI; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Scripting; using UnityEngine.SceneManagement; using MVR.FileManagementSecure; public class UserPrefNavigation : MVRScript {// @14mhz test code bool DBGLOG = false; JSONStorableString info; public override void Init() { StartCoroutine(waitInitialized(this)); addButton(this, true, "Get Navigation Info", navigation); info = addInfo(this, false, 400); } void Start() { if (DBGLOG) SuperController.LogMessage($"[INF] Start"); } void OnGUI() { } void Update() { } void FixedUpdate() { } void LateUpdate() { } void Awake() { if (DBGLOG) SuperController.LogMessage($"[INF] Awake"); } void OnEnable() { SceneManager.sceneLoaded += OnSceneLoaded; if (DBGLOG) SuperController.LogMessage($"[INF] OnEnable"); } void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (DBGLOG) SuperController.LogMessage($"[INF] OnSceneLoaded"); } void OnDisable() { SceneManager.sceneLoaded -= OnSceneLoaded; if (DBGLOG) SuperController.LogMessage($"[INF] OnDisable"); } void OnDestroy() { if (DBGLOG) SuperController.LogMessage($"[INF] OnDestroy"); } void navigation() { if (NAVI == null) { SuperController.LogMessage($"[INF] Cannot Find Navigation Root ..."); return; } Toggle DisableAllNavigationToggle = NAVI.Find("DisableAllNavigationToggle").GetComponentsInChildren(true).FirstOrDefault(); Toggle DisableGrabNavigationToggle = NAVI.Find("DisableGrabNavigationToggle").GetComponentsInChildren(true).FirstOrDefault(); Toggle DisableTeleportToggle = NAVI.Find("DisableTeleportToggle").GetComponentsInChildren(true).FirstOrDefault(); Toggle DisableTeleportDuringPossessToggle = NAVI.Find("DisableTeleportDuringPossessToggle").GetComponentsInChildren(true).FirstOrDefault(); Toggle TeleportAllowRotationToggle = NAVI.Find("Teleport Allow Rotation Toggle").GetComponentsInChildren(true).FirstOrDefault(); Slider GrabNavigatePositionMultiplier = NAVI.Find("GrabNavigatePositionMultiplier").GetComponentsInChildren(true).FirstOrDefault(); Slider GrabNavigateRotationMultiplier = NAVI.Find("GrabNavigateRotationMultiplier").GetComponentsInChildren(true).FirstOrDefault(); Slider FreeNavigateMultiplier = NAVI.Find("FreeNavigateMultiplier").GetComponentsInChildren(true).FirstOrDefault(); Slider HologridTransparency = NAVI.Find("HologridTransparency").GetComponentsInChildren(true).FirstOrDefault(); Toggle ShowHologridToggle = NAVI.Find("ShowHologrid Toggle").GetComponentsInChildren(true).FirstOrDefault(); String mesg = ""; mesg += $"[INF] DisableAllNavigation [{DisableAllNavigationToggle.isOn}]" + "\n"; mesg += $"[INF] DisableGrabNavigation [{DisableGrabNavigationToggle.isOn}]" + "\n"; mesg += $"[INF] DisableTeleport [{DisableTeleportToggle.isOn}]" + "\n"; mesg += $"[INF] DisableTeleportPossess [{DisableTeleportDuringPossessToggle.isOn}]" + "\n"; mesg += $"[INF] TeleportAllowRotation [{TeleportAllowRotationToggle.isOn}]" + "\n"; mesg += $"[INF] GrabNavigatePosition [{GrabNavigatePositionMultiplier.value}]" + "\n"; mesg += $"[INF] GrabNavigateRotation [{GrabNavigateRotationMultiplier.value}]" + "\n"; mesg += $"[INF] FreeNavigate [{FreeNavigateMultiplier.value}]" + "\n"; mesg += $"[INF] HologridTransparency [{HologridTransparency.value}]" + "\n"; mesg += $"[INF] ShowHologridToggle [{ShowHologridToggle.isOn}]" + "\n"; info.val = mesg; } /////////////////////////////////////////////////////////////////////////// public static UIDynamicButton addButton(MVRScript script, bool leftSide, string label, UnityAction callback) { UIDynamicButton button = script.CreateButton(label, !leftSide); button.button.onClick.AddListener(callback); return button; } public static JSONStorableString addInfo(MVRScript script, bool leftSide, float height) { JSONStorableString storable = new JSONStorableString("Info", ""); UIDynamic textfield = script.CreateTextField(storable, !leftSide); textfield.height = height; return storable; } static Transform corecontrol(Transform t) { if (t == null) return null; if (t.name == "SceneAtoms") return t.Find("CoreControl"); return corecontrol(t.parent); } Transform CORE = null; Transform PREF = null; Transform NAVI = null; public IEnumerator waitInitialized(MVRScript script) { while (SuperController.singleton.isLoading) yield return null; while (script.UITransform == null || script.UITransform.GetComponentInChildren() == null) yield return null; CORE = corecontrol(script.UITransform); PREF = CORE == null ? null : CORE.Find("WorldScaleAdjust/HUD/MainUICanvas/Panel/Content/TabUserPrefs/Content/TabGroup"); NAVI = PREF == null ? null : PREF.GetComponentsInChildren(true).FirstOrDefault(t => t.name == "DisableAllNavigationToggle")?.parent; if (NAVI == null) yield break; } }