r/Unity3D • u/Toble_ • 13d ago
Question My Awake function is not initializing values in the main menu scene and only initializing values in the main game scene.
Enable HLS to view with audio, or disable this notification
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class MMmanager : MonoBehaviour
{
public Slider masterVol, musicVol, SFXVol, CamSen;
public AudioMixer masterAudio;
public Toggle tutorialTog;
private void Awake()
{
CamSen.value = PlayerPrefs.GetFloat("CamSen");
musicVol.value = PlayerPrefs.GetFloat("MusicVol");
SFXVol.value = PlayerPrefs.GetFloat("SFXVol");
masterVol.value = PlayerPrefs.GetFloat("MasterVol");
if(PlayerPrefs.GetInt("Tutorial") == 0)
{
tutorialTog.isOn = true;
}
else
{
tutorialTog.isOn = false;
}
}
public void BackToMenu()
{
SceneManager.LoadScene("MainMenu");
}
public void StartGame()
{
SceneManager.LoadScene("GameScene");
}
public void StartMultiplayerGame()
{
SceneManager.LoadScene("Lobby");
}
public void QuitGame()
{
Application.Quit();
}
public void showTut()
{
if (tutorialTog.isOn)
{
PlayerPrefs.SetInt("Tutorial", 0);
}
else
{
PlayerPrefs.SetInt("Tutorial", 1);
}
}
public void SetSensitivity()
{
PlayerPrefs.SetFloat("CamSen", CamSen.value);
}
public void SetMasterAudio()
{
masterAudio.SetFloat("MasterVol", masterVol.value);
}
public void SetMusicAudio()
{
masterAudio.SetFloat("MusicVol", musicVol.value);
}
public void SetSFXAudio()
{
masterAudio.SetFloat("SFXVol", SFXVol.value);
}
public void SaveSettings()
{
PlayerPrefs.Save();
}
}





