Search Unity

[SOLVED] New UI Toggle between scenes

Discussion in 'Immediate Mode GUI (IMGUI)' started by No-jo, Oct 4, 2014.

  1. No-jo

    No-jo

    Joined:
    Aug 30, 2014
    Posts:
    8
    Hey,

    I'm enjoying the simplicity if the new UI system but I was wondering if someone could tell me how to maintain a toggle event between scenes.

    I have a mute button that is working well with the follow script on the On value changed (boolean) section.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class ToggleMusic : MonoBehaviour {
    5.  
    6.     public void click()
    7.     {
    8.         GlobalVar.music = !GlobalVar.music;
    9.         Debug.Log(GlobalVar.music);
    10.     }
    11. }
    12.  
    The problem is when i move to another scene the button is reset and now my music is toggled in reverse. Obviously if the music is muted I need the correct image showing.

    EDIT: I want the sound settings saved for the next time the user loads the app. So I need the toggle button boolean to always equal the GlobalVar.music boolean.

    Any help would be appreciated. Thanks.
     
    Last edited: Oct 4, 2014
  2. No-jo

    No-jo

    Joined:
    Aug 30, 2014
    Posts:
    8