- Home /
Issues enabling/disabling Image Effects programmatically (js)
Hello All,
I'm working on a game's menu system which should be able to apply (enable/disable) image effects on the main camera while paused. My code, below, produces an error that I've tried searching for a solution to, but haven't been able to figure out.
My code:
public var mainCamera : Camera;
private var grayScreen : boolean = true;
function Start () {
var grayScreen : GrayscaleEffect = mainCamera.GetComponent(GrayscaleEffect);
}
And, where it is called:
function OpenConsole () {
Debug.Log ("Opening Console");
grayScreen.enabled = true;
consoleMenuOpen = true;
}
When I try using this code, the following MissingFieldException error is returned once it attempts to enable the grayscale effect:
I've tried replacing grayScreen.enabled with grayScreen.active, to no avail.
Your answer
Follow this Question
Related Questions
Missing Field Exception 1 Answer
Missing Field Exception 1 Answer
Field 'UnityEngine.Vector3.transform' not found 1 Answer
Unable to disable gameObject with children 1 Answer
ERROR: Missing field exception?! 1 Answer