Search Unity

  1. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Let us know a bit about your interests, and if you'd like to become more directly involved. Take our survey!
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. 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:
    19
    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