- Home /
Show mouse click feedback on textured 2d plane button
I have a button that is a plane with a texture on. I need a way for the user to tell if it has been clicked. Is there something about the material I can change to make it look darker or lighter?
Changing material properties has no effect. material.color=Color(1,1,1,1) etc. does not change the texture. The shader I'm using is Unlit/Transparent.
Answer by CostelloNicho · Nov 13, 2012 at 11:54 PM
From a quick look at the Unlit transparent shader, there looks like there is no color property to manipulate. The best way to do this would be to have a second Texture with a lowered alpha to toggle between.
If you don't want to change the color or make another texture, you could always do a small animation to indicate that it has been pressed.
Is it possible to add color to this if it's unlit? How would I do that and save the shader so I can use it?
Sorry for the late response, I do not have the answer you seek. I have not had the chance just yet to jump into manipulating shaders. I do know of a great tutorial series I'm planning to go through sometime soon, you should check it out, here is part one:
Answer by IgnoranceIsBliss · Nov 14, 2012 at 12:06 AM
Some Options:
You could create a new shader based on the Unlit Transparent one, and give it a colour property that you can then change at runtime. Then you'd be able to use your existing code.
Change the texture when the mouse is hovering over it.
Draw the item in 2D using GUI (this assumes your button isn't SUPPOSED to be a 3D object) and use GUI.color to influence both colour and transparency.
Does anyone know how to modify this shader from the script to change a property that might make it look like it's getting darker.
// Unlit alpha-cutout shader. // - no lighting // - no lightmap support // - no per-material color
Shader "Unlit/Transparent Cutout" {
Properties {
_$$anonymous$$ainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
}
SubShader {
Tags {"Queue"="AlphaTest" "IgnoreProjector"="True" "RenderType"="TransparentCutout"}
LOD 100
Pass {
Lighting Off
Alphatest Greater [_Cutoff]
SetTexture [_$$anonymous$$ainTex] { combine texture }
}
}
}
Your answer
Follow this Question
Related Questions
Make a Button out of a Textured Plane 2 Answers
Normal map strange shading lines. 0 Answers
Make a plane show the cameras "fov" 0 Answers