public void HideMenu() { RestoreCursorState(); if (overlayCam != null) { overlayCam.enabled = true; } if (overlay != null) { overlay.uvOffset = uvOffset; overlay.distance = distance; overlay = null; } }
public void ShowMenu() { var overlay = SteamVR_Overlay.instance; if (overlay == null) { return; } var texture = overlay.texture as RenderTexture; if (texture == null) { Debug.LogError("Menu requires overlay texture to be a render texture."); return; } SaveCursorState(); Cursor.visible = true; Cursor.lockState = CursorLockMode.None; this.overlay = overlay; uvOffset = overlay.uvOffset; distance = overlay.distance; // If an existing camera is rendering into the overlay texture, we need // to temporarily disable it to keep it from clearing the texture on us. var cameras = Object.FindObjectsOfType(typeof(Camera)) as Camera[]; foreach (var cam in cameras) { if (cam.enabled && cam.targetTexture == texture) { overlayCam = cam; overlayCam.enabled = false; break; } } var tracker = SteamVR_Render.Top(); if (tracker != null) { scale = tracker.origin.localScale.x; } }