Well, I have a few image affecting scripts such as antialiasing, bloom, sunshafts, colorcorrection etc… And in an options section of my pause menu, I want to add the option of either disabling them or enabling them. Specifically right now I am working with the Sun Shafts. I set it up to that when I click a button on the UI, it calls the function “selectSunShafts()” which disables the SunShafts script on the FirstPersonCharacter under unity’s standard FPS Controller. Sadly when I play test in Unity, I get the error “NullReferenceException”. I have tried to disable this many ways and none are working. Any help would be greatly appreciated.
using UnityEngine;
using UnityStandardAssets.Characters.FirstPerson;
using UnityEngine.UI;
public class Options : MonoBehaviour {
public Text sunShafts;
void Awake()
{
sunShafts.text = "On";
}
public void selectSunShafts()
{
GameObject fpc = GameObject.Find("FirstPersonCharacter");
fpc.GetComponent<SunShafts>().enabled = false;
sunShafts.text = "Off";
}
}