So I am trying to create an audio options menu however it is coming up with the following error:
NullReferenceException: Object reference not set to an instance of an object
AudioOptions_Master.Start () (at Assets/Scripts/UI/Standard Menus/Options Menu/Sound/AudioOptions_Master.cs:26)
However, everything is assigned in the inspector.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AudioOptions_Master : MonoBehaviour
{
public Button BTN_MuteMaster;
public Button BTN_TestMaster;
public Color Color_BTN_Sound;
public Color Color_BTN_Muted;
public Color Color_TXT_Sound;
public Color Color_TXT_Muted;
public float FLT_Master;
public float FLT_MasterBackup;
public Slider SLI_Master;
public Text TXT_Master;
public Text TXT_BTN_MuteMaster;
public void Start ( )
{
BTN_MuteMaster.onClick.AddListener ( Mute_Master );
}
public void Mute_Master ( )
{
if ( FLT_Master == 0.0f )
{
// Restore Backup
FLT_Master = FLT_MasterBackup;
// Change Color
BTN_MuteMaster.GetComponent<UnityEngine.UI.Image> ( ).color = Color_BTN_Sound;
}
else
{
// Set Backup
FLT_MasterBackup = FLT_Master;
// Mute Master Audio
FLT_Master = 0.0f;
// Change Color
BTN_MuteMaster.GetComponent<UnityEngine.UI.Image> ( ).color = Color_BTN_Muted;
}
}
}