Hi I am using the new 4.6 unity UI feature and I have two seperate scenes. One for my options and one for my game. How can I connect both together so I can get things such as the fov working with the game camera and make it work when i press esc
So you have your options menu in one scene and your game in another and you want to be able to open your menu from the game?
-
Start in your menu scene
-
Make your options ui hierarchy a prefab
-
Go to your game scene
-
Drag in your prefab (Make sure you have a canvas in there and that the prefab is a child of it)
-
Write a script that toggles the menu when you press ESC:
using UnityEngine;
public class ToggleMenu : MonoBehaviour {
public GameObject optionsMenu; void Update () { if(Input.GetKeyDown(KeyCode.Escape)){ optionsMenu.SetActive(!optionsMenu.activeSelf); } }
}
-
Put script on Canvas (or anywhere really)
-
Drag your options menu top-level gameobject into the optionsMenu field on the ToggleMenu script in the inspector
-
Revel in your new game menu!