Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Resolved toggle switch sprite

Discussion in 'Audio & Video' started by houssamess, Jun 1, 2020.

  1. houssamess

    houssamess

    Joined:
    Aug 24, 2018
    Posts:
    4
    hello i have a toggle button to control my audio. The sprite changes everytime i push the button and the sound is on/off also. The problem is that when i change scene and comeback the sprite is back to what it was before i touch the button. I know i need to use PlayerPrefs to save my button sprite through scenes but i dont know how to implemant that on my script: This is my button manager script :

    using UnityEngine;
    using System.Collections;
    using UnityEngine.SceneManagement;


    public class Buttonmanager : MonoBehaviour
    {
    public void Newgamebtn(string newGameLevel)
    {
    Time.timeScale = 1f;
    SceneManager.LoadScene(newGameLevel);

    }

    public void ExitGameBtn()
    {
    Application.Quit();
    }


    public void Mute()
    {
    AudioListener.pause = !AudioListener.pause;
    }
    }


    thank you in advance for your help
     
  2. marc_tanenbaum

    marc_tanenbaum

    Unity Technologies

    Joined:
    Oct 22, 2014
    Posts:
    637
    Hi there! This isn't really an audio question so much as a coding question, but let's see if we can point you in the right direction.. A video like this one should explain what you need to know.
     
  3. houssamess

    houssamess

    Joined:
    Aug 24, 2018
    Posts:
    4
    Thank you .