Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Bentoon · Dec 31, 2013 at 06:32 AM · visibility

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

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bentoon · Dec 31, 2013 at 03:42 PM 0
Share

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

avatar image
0

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

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

19 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges