- Home /
Image effect on button down
how to you have an image effect on a button down? I'm new with unity and i don't know where to start.I'm trying to make a color correction happen when you press z.
To get you started:
void Update(){
if(Input.Get$$anonymous$$eyDown("Z"))
{*your code here*}
}
You need to assign a meaning to "Z" by going to Edit->Project Settings->Input
Let's just correct that real quick:
void Update(){
if(Input.Get$$anonymous$$eyDown($$anonymous$$eyCode.Z))
{
//Your code here
}
}
To clarify: Nobody can answer because you did a really bad job at submitting a clear question.
No one can tell you how to make your 'image effect' or 'color correction' because you didn't specify what is supposed to happen.
You can't just write vague stuff like 'move player forward' in code, what you can write is 'take gameobject 'player' and move it with a speed of X in the direction it is facing'.
If you want people do make the effort to help you, you should first make the effort to make it as easy as you can to help you.
I'm sorry, i'm new to unity and this website, i guess i didn't clarify properly . What i need it for when the "Z" button is pressed it applies a color correction or some other effect that will sharpen the colors. $$anonymous$$y game is a robin hood themed s$$anonymous$$lth game. The main character has a focus ability that when the z button is pressed it zooms in ,and sharpens the colors. I really am sorry for the inconvenience
Answer by skylem · Feb 23, 2015 at 08:49 AM
you can access all components in unity through scripting Anything u see in your InspectorWindow(the window that holds ur transform), some of these components include MeshRenderers and there corrosponding materials, as u may or may not be aware a material holds data for the objects texture and color u could simply change the color of a material or you could change the material itself, i don't know exactly what u mean by "Color Correction" but i'd hazard a guess that a Material is what you need heres an example
public MeshRenderer mesh; // drag/drop the object we want to affects color to this field in the inspector.
public Material newmat; //drag/drop the material we change to here.
public Color custColor; // if we just want to change the color.
// place the following in update
if(Input.GetKeyDown(Keycode.Tab)) {
mesh.material = newmat;
// or if we just want to change the current materials color
mesh.material.color = custColor;
}
Your answer
Follow this Question
Related Questions
Setting Scroll View Width GUILayout 1 Answer
Can someone help me fix my Javascript for Flickering Light? 6 Answers
Shotgun using array/list in Javascript 1 Answer
How to let my gun shoot ?? 0 Answers