|
I have a selection script here in C# that causes objects to turn Color.green when the mouse is over. The script previously did Color.white upon mouse exit. However the team and I are now using the color properties of the materials to get more variety in our planets, and for other effects. So, we need the color of the object with the script attached to return to the original color of that object and not any other which the mouse may have been over. Here's my code thus far. This is a per object script that we only place on select-able or camera focus-able objects. The sections with the cursorLock element are for keeping the object at the center of screen and camera focus from turning green when the player rotates the camera.
(comments are locked)
|
|
In the start function assign the 'original' variables color not in the update, it only needs to be assigned once at start then onmouseexit will work. Tried that! Material always turns black on mouse exit.
Mar 31 '12 at 01:45 PM
thundax
(comments are locked)
|
|
In the start function assign the 'original' variables color not in the update, it only needs to be assigned once at start then onmouseexit will work.
(comments are locked)
|
|
Well there are a lot things that looks a bit strange.
I would do something like that: Gotcha! Also I tried putting "originalColor = renderer.material.color;" in "void Start". The material always turns black on mouse exit. I also can't use onMouseEnter because the selection stuff doesn't work right with that because it is only called once. The "objectName", "targetName", and "qFocus" are to pass to the smoothfollow, orbit, and camera control script (all one script). I use a switchable parenting or position based smooth follow and focus. I'll try your naming conventions and see if that helps. Otherwise I've basically already done what you posted here in the past. Thanks for the help though.
Mar 31 '12 at 01:54 PM
thundax
Just as I thought. This still causes the object to turn black upon MouseExit. Any other ideas?
Mar 31 '12 at 02:02 PM
thundax
(comments are locked)
|

I think I don't get it, you have an object that is let's say white and it turns green when you hover over, and you want it back to white when the mouse is not over anymore, is that so? Just use function Start{renderer.material.color = white;} OnMouseOver{renderer.material.color = green; } OnMouseExit{renderer.material.color = white; } Is it?
Sorta. I have an object that has a custom material color setting. Not white! So I can't tell it renderer.material.color = Color.white because that wouldn't return it to it's original state before mouse over upon mouse exit.