Skip to content

Commit

Permalink
Visible pause menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Raicuparta committed Jan 6, 2020
1 parent cae3e28 commit 072c037
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions NomaiVR/NomaiVR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,51 @@
using OWML.ModHelper;
using OWML.ModHelper.Events;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.XR;
using UnityEngine.SceneManagement;

namespace OWML.NomaiVR
{
public class NomaiVR : ModBehaviour
{
private void Start() {
void Start() {
SceneManager.sceneLoaded += OnSceneLoaded;
MoveMainMenuToWorldSpace();
}

void OnDisable() {
SceneManager.sceneLoaded -= OnSceneLoaded;
}

void OnSceneLoaded(Scene scene, LoadSceneMode mode) {
MovePauseMenuToWorldSpace();
}

void MoveMainMenuToWorldSpace() {
Canvas[] canvases = Object.FindObjectsOfType<Canvas>();

ModHelper.Console.WriteLine("found " + canvases.Length + " canvases.");
foreach (Canvas canvas in canvases) {
canvas.renderMode = RenderMode.WorldSpace;
Transform originalParent = canvas.transform.parent;
canvas.transform.parent = Object.FindObjectOfType<Camera>().transform;
canvas.transform.localPosition = new Vector3(-50, -30, 200);
canvas.transform.localPosition = new Vector3(0, 0, 1);
canvas.transform.localRotation = new Quaternion(0, 0, 0, 1);
canvas.transform.localScale = Vector3.one * 0.2f;
canvas.transform.parent = null;
canvas.transform.localScale = Vector3.one * 0.0005f;
}
}

private void Update() {
void MovePauseMenuToWorldSpace() {
GameObject pauseMenu = GameObject.Find("PauseMenu");
Canvas[] canvases = pauseMenu.GetComponentsInChildren<Canvas>();
Camera playerCamera = GameObject.Find("PlayerCamera").GetComponent<Camera>();

foreach (Canvas canvas in canvases) {
canvas.renderMode = RenderMode.WorldSpace;
}

pauseMenu.transform.parent = playerCamera.transform;
pauseMenu.transform.localPosition = new Vector3(-0.6f, -0.5f, 1);
pauseMenu.transform.localEulerAngles = new Vector3(0, 0, 0);
pauseMenu.transform.localScale = Vector3.one * 0.001f;
}

}
Expand Down

0 comments on commit 072c037

Please sign in to comment.