// Update is called once per frame void Update() { DebugUIBuilder ui = DebugUIBuilder.instance; if (Application.platform == RuntimePlatform.Android) { // retrieve + update launch details Oculus.Platform.Models.LaunchDetails launchDetails = Oculus.Platform.ApplicationLifecycle.GetLaunchDetails(); uiLaunchType.GetComponentInChildren <Text>().text = "LaunchType: " + launchDetails.LaunchType; uiLaunchSource.GetComponentInChildren <Text>().text = "LaunchSource: " + launchDetails.LaunchSource; uiDeepLinkMessage.GetComponentInChildren <Text>().text = "DeeplinkMessage: " + launchDetails.DeeplinkMessage; } if (OVRInput.GetDown(OVRInput.Button.Two) || OVRInput.GetDown(OVRInput.Button.Start)) { if (inMenu) { DebugUIBuilder.instance.Hide(); } else { DebugUIBuilder.instance.Show(); } inMenu = !inMenu; } }
// Start is called before the first frame update void Start() { DebugUIBuilder ui = DebugUIBuilder.instance; uiLaunchType = ui.AddLabel("UnityDeeplinkSample"); ui.AddDivider(); ui.AddButton("launch OtherApp", LaunchOtherApp); ui.AddButton("launch UnrealDeeplinkSample", LaunchUnrealDeeplinkSample); deeplinkAppId = CustomDebugUI.instance.AddTextField(UNITY_COMPANION_APP_ID.ToString(), 0); deeplinkMessage = CustomDebugUI.instance.AddTextField("MSG_UNITY_SAMPLE", 0); ui.AddButton("LaunchSelf", LaunchSelf); if (Application.platform == RuntimePlatform.Android) { // init ovr platform if (!Oculus.Platform.Core.IsInitialized()) { Oculus.Platform.Core.Initialize(); } } uiLaunchType = ui.AddLabel("LaunchType: "); uiLaunchSource = ui.AddLabel("LaunchSource: "); uiDeepLinkMessage = ui.AddLabel("DeeplinkMessage: "); ui.ToggleLaserPointer(true); ui.Show(); }
public void Awake() { Debug.Assert(instance == null); instance = this; menuOffset = transform.position; // TODO: this is unpredictable/busted //gameObject.SetActive(false); rig = FindObjectOfType <OVRCameraRig>(); for (int i = 0; i < toEnable.Count; ++i) { toEnable[i].SetActive(false); } insertPositions = new Vector2[targetContentPanels.Length]; for (int i = 0; i < insertPositions.Length; ++i) { insertPositions[i].x = marginH; insertPositions[i].y = -marginV; } insertedElements = new List <RectTransform> [targetContentPanels.Length]; for (int i = 0; i < insertedElements.Length; ++i) { insertedElements[i] = new List <RectTransform>(); } if (uiHelpersToInstantiate) { GameObject.Instantiate(uiHelpersToInstantiate); } lp = FindObjectOfType <LaserPointer>(); if (!lp) { Debug.LogError("Debug UI requires use of a LaserPointer and will not function without it. Add one to your scene, or assign the UIHelpers prefab to the DebugUIBuilder in the inspector."); return; } lp.laserBeamBehavior = laserBeamBehavior; if (!toEnable.Contains(lp.gameObject)) { toEnable.Add(lp.gameObject); } GetComponent <OVRRaycaster>().pointer = lp.gameObject; lp.gameObject.SetActive(false); #if UNITY_EDITOR string scene = SceneManager.GetActiveScene().name; OVRPlugin.SendEvent("debug_ui_builder", ((scene == "DebugUI") || (scene == "DistanceGrab") || (scene == "OVROverlay") || (scene == "Locomotion")).ToString(), "sample_framework"); #endif }
public void RemoveFromCanvas(RectTransform element, int targetCanvas = 0) { DebugUIBuilder ui = DebugUIBuilder.instance; var field = typeof(DebugUIBuilder).GetField("insertedElements", privateFlags); var relayout = typeof(DebugUIBuilder).GetMethod("Relayout", privateFlags); List <RectTransform>[] elements = (List <RectTransform>[])field.GetValue(ui); if (targetCanvas > -1 && targetCanvas < elements.Length - 1) { elements[targetCanvas].Remove(element); element.SetParent(null); relayout.Invoke(ui, new object[] { }); } }
public RectTransform AddTextField(string label, int targetCanvas = 0) { RectTransform textRT = GameObject.Instantiate(textPrefab).GetComponent <RectTransform>(); InputField inputField = textRT.GetComponentInChildren <InputField>(); inputField.text = label; DebugUIBuilder ui = DebugUIBuilder.instance; var addRect = typeof(DebugUIBuilder).GetMethod("AddRect", privateFlags); addRect.Invoke(ui, new object[] { textRT, targetCanvas }); return(textRT); }