- Home /
onMouseDown controlling visibility
Hello, I'm newbie & just learning Js
I have many textured planes near them are other textured planes with their mesh off so they are hidden.
I want to create a script to click on one plane and have the visibility of the other turn on I have to do this for a number of assets so I am wondering a) how to do this and b) wondering if there is not a way to automate it somehow with dragging both planes into a game object
but the script I have for the first part of my question doesn’t even work
function OnMouseUp( ) {
if (Plane_3b.renderer.enabled = false) {
Plane_3b.renderer.enabled = true;
}
if (Plane_3b.renderer.enabled = true) {
Plane_3b.renderer.enabled = false;
}
}
Thank you in advance best, b
Answer by Patel-Sagar · Dec 31, 2013 at 07:02 AM
it's not working bcoz you have written both conditions in If...so it always goes to 2nd if.
second condition should be 'else if'... its working then.
Aha! Thanks Patel but it still didn't work error message was expecting an ) ins$$anonymous$$d of "=" so I changed it to :
function On$$anonymous$$ouseDown( ) { // if (Plane_3b.renderer.enabled = false) { // Plane_3b.renderer.enabled = true; if (Plane_3b.renderer.disabled) { Plane_3b.renderer.enabled; } else if //(Plane_3b.renderer.enabled = true) { // Plane_3b.renderer.enabled = false; (Plane_3b.renderer.enabled) { Plane_3b.renderer.disabled; } }
But the problem is now identifying the specific plane. In the hierarchy it is called Plane_2b, but it's an "unknown identifier" ? Thanks J
Answer by Bentoon · Jan 03, 2014 at 01:19 AM
The problem is now identifying the specific plane. In the hierarchy it is called Plane_3b, but it's an "unknown identifier" ???
function OnMouseDown( ) {
if (Plane_3b.renderer.disabled) {
Plane_3b.renderer.enabled;
}
else if (Plane_3b.renderer.enabled) {
Plane_3b.renderer.disabled;
}
}
Thanks J
Your answer
Follow this Question
Related Questions
appear/disappear gameobject 3 Answers
simple invisibility 1 Answer
Unhide unseen objects. 1 Answer
Fog Of War/ Visibility 0 Answers
Always Show Distant Objects? 1 Answer