Alright, so I’m currently developing a 3D platformer game, and I am working on an options bug. This bug being that I can turn a bool to false, and then I go into a level, go back into the same menu Scene, and the music starts playing even though I turned it off before. I am using a toggle to turn on and off the bool.
Here is my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Options : MonoBehaviour
{
public static bool isMusic;
public static bool isCoinSFX;
void Start()
{
isMusic = true;
isCoinSFX = true;
}
void Update()
{
}
public void MusicValueChange()
{
isMusic = !isMusic;
}
public void CoinSFXChange()
{
isCoinSFX = !isCoinSFX;
}
}
Yes, I know I have to remove the code in the Start, but then the Toggle will be inverted. (When it’s toggled off, the music is on and vise versa) Please help if you see this and know the answer.