hi i have a simple game ive made and applied the grayscale effect from the standard assets to my camera
This script has a ramp offset value and im wondering how i can have a keypress that would cycle through three different values…
like if i press 1 it would cycle between a value of
1
2
or 3
[9148-question+about+gamma.png|9148]
Here is a script that should work. Attach to the camera and setup the ‘Ramp Vals’ array in the Inspector.
#pragma strict
var rampVals : float[];
private var iVal = 0;
private var ge : GrayscaleEffect;
function Start () {
if (rampVals == null)
Debug.Log("Set the 'Ramp Vals' in the Inspector");
ge = GetComponent(GrayscaleEffect);
ge.rampOffset = rampVals[0];
}
function Update () {
if (Input.GetKeyDown(KeyCode.A)) {
iVal = (iVal + 1) % rampVals.Length;
ge.rampOffset = rampVals[iVal];
}
}