Executing Actions Through PlayerPrefs
Hey, I'm working on a game that has an "options" scene where players can change the options. I have only coded my first option: the Audio, but it doesn't seem to be working. What I want it to do is change a playerpref value when a button is clicked on, and then use that value to do different things: I have two scripts for the buttons being pressed:
#pragma strict
function OnMouseUp ()
{
PlayerPrefs.SetInt("Audio", 0);
}
and I also have:
#pragma strict
function OnMouseUp ()
{
PlayerPrefs.SetInt("Audio", 1);
}
The script that executes the action is :
function Update ()
{
PlayerPrefs.GetInt("Audio");
if Audio== 1
{
GameObject.Find("audioon").GetComponent(SpriteRenderer).enabled = false;
GameObject.Find("audioon1").GetComponent(SpriteRenderer).enabled = true;
GameObject.Find("audiooff").GetComponent(SpriteRenderer).enabled = true;
GameObject.Find("audiooff1").GetComponent(SpriteRenderer).enabled = false;
AudioListener.volume = 1;
}
if Audio==0
{
GameObject.Find("audioon").GetComponent(SpriteRenderer).enabled = true;
GameObject.Find("audioon1").GetComponent(SpriteRenderer).enabled = false;
GameObject.Find("audiooff").GetComponent(SpriteRenderer).enabled = false;
GameObject.Find("audiooff1").GetComponent(SpriteRenderer).enabled = true;
AudioListener.volume = 0;
}
}
If you look where I put if "Audio== x" I didn't know what to put there.
Answer by LunarSolstice · Jan 16, 2017 at 03:55 AM
Actually I fixed this a few days ago, I don't need help anymore.
Your answer
![](https://koobas.hobune.stream/wayback/20220612104548im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Using an audio listener as a output clip 1 Answer
One Shot Sound After Countdown JS 1 Answer
How can I represent the highpass filter with a curve like the lowpass filter? 0 Answers
Audio Endless Loop c# 1 Answer
WOW audio effect 0 Answers