Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    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 .