- Home /
Question by
joseaguirre · Mar 20, 2013 at 10:30 PM ·
camerabuttonvalueimage effectscycle
Ramp Offset with Button press
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
question about gamma.png
(70.7 kB)
Comment
Best Answer
Answer by robertbu · Mar 21, 2013 at 03:00 AM
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];
}
}