Search Unity

  1. Unity 2018.1 has arrived! Read about it here
    Dismiss Notice
  2. Scriptable Render Pipeline improvements, Texture Mipmap Streaming, and more! Check out what we have in store for you in the 2018.2 Beta.
    Dismiss Notice
  3. If you couldn't join the live stream, take a peek at what you missed.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  5. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  6. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  7. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Unity UI Options Menu

Discussion in 'Unity UI & TextMesh Pro' started by wishingchain, Jun 6, 2018.

  1. wishingchain

    wishingchain

    Joined:
    Oct 5, 2016
    Posts:
    25
    Hi, I was wondering how to make a options menu that you can access at anytime that can change the resolution/volume and other stuff from in game without resetting your position. Is it also possible to save your current progress in the game? I am using this script right now that just loads a new scene to play the game. I removed the Options void as I could not get it working. Any help would be appreciated, thanks.

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.SceneManagement;
    5.  
    6. public class MainMenu : MonoBehaviour {
    7.  
    8.  
    9.     public void PlayGame()
    10.     {
    11.         SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex +1);
    12.     }
    13.  
    14.     public void Options()
    15.     {
    16.         SceneManager.LoadScene(2);
    17.     }
    18.  
    19.     public void Optionsback()
    20.     {
    21.         SceneManager.LoadScene(0);
    22.     }
    23.  
    24.  
    25.     public void QuitGame()
    26.     {
    27.         Debug.Log("Quitting...");
    28.         Application.Quit();
    29.     }
    30.  
    31. }
    32.  
     
  2. hjohnsen

    hjohnsen

    Joined:
    Feb 4, 2018
    Posts:
    5
    For your option, search for "pause menu" in the script sub forum I think or on google. You do not need to load another scene to do that, you can have some hidden canvas. For example :


    Code (CSharp):
    1.     public static void HideUI(GameObject gameObject)
    2.     {
    3.         HideUI( gameObject.GetComponent<CanvasGroup>() );
    4.     }
    5.  
    6.     public static void HideUI(CanvasGroup cg)
    7.     {
    8.         cg.interactable = false;
    9.         cg.alpha = 0;
    10.     }
    11.  
    12.     public static void ShowUI(GameObject gameObject)
    13.     {
    14.         ShowUI( gameObject.GetComponent<CanvasGroup>() );
    15.     }
    16.  
    17.     public static void ShowUI(CanvasGroup cg)
    18.     {
    19.         cg.interactable = true;
    20.         cg.alpha = 1.0f;
    21.     }
    22.  
    23.  
    For state saving you should search the script forum too.
     
    wishingchain likes this.
  3. wishingchain

    wishingchain

    Joined:
    Oct 5, 2016
    Posts:
    25
    Thanks, I just did this and it works perfectly