- Home /
Two png mouse down detect
Hi, I am new to unity having some problem on png texture. i am having two png texture one behind another. if i click on the upper png transparent part still i am getting the upper png texture name.. I want that if i click on the transparent part of the png texture i should get the name of the png texture below it .. pls do help me thanks
Answer by sfc.itzhak · Aug 16, 2012 at 07:28 AM
remove the colider of the first one .
i am guessing you are yousing onmouseup or raycasting.
thanks for your reply.. i am using onmousedown i removed the colider but now the upper texture is not clickable .. i want both to be clickable but on the transparent area it should not be clickable it should give me the name of the object behind it these is the script which i am attaching on both of the object --- Script ---- function On$$anonymous$$ouseDown() { Debug.Log("On$$anonymous$$ouseDown "+transform.name); }
Answer by santoshbhagat · Aug 17, 2012 at 09:28 AM
thanks for your reply.. i am using onmousedown i removed the colider but now the upper texture is not clickable .. i want both to be clickable but on the transparent area it should not be clickable it should give me the name of the object behind it these is the script which i am attaching on both of the object --- Script ---- function OnMouseDown() { Debug.Log("OnMouseDown "+transform.name); }
Answer by sfc.itzhak · Aug 21, 2012 at 07:23 PM
for some reason my responce didnt showed.
you have 2 options: 1. change the coliders so the bottom png colider will be a the place of the hole and will be above the first colider.
when you click you will need to raycast and see whats the color at the point that you hit and go from that http://docs.unity3d.com/Documentation/ScriptReference/Texture2D.GetPixel.html
sfc.
Your answer
Follow this Question
Related Questions
On Pointer Enter for semi-transparent UI? 2 Answers
Transparency Issue with Large Object 0 Answers
Export PNG with alpha containing a semi transparent texture 1 Answer
what happened to transperancy? 0 Answers