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
1
Question by User · Dec 31, 2010 at 07:45 PM · instantiateobjectsselectdeselect

how to select and deselct an instantiated objects.

Hello

I am making a script. When i press the button a gameobject is instantiated. When i press button again then the another gameobject(clone) is instantiated. What i want to do is make a select and deselect between gameobjects. Lets say that i instantiate 10 objects when game is running. Then i select one gameobject and it turns red. Now i want that if i select another gameobject the the first gameobject will deselect itself and new chosed gameobject will be red.

Basically i dont want to be able to choose more than 1 object. Right now my have made is so that i can select and deselect all the gameobjects when i klick on them. But i just want to able to select one gameobject. And after i select another the first one will get deselected by default.

If this were static objects i just could do a bunch of static boolean fields and make a simple (if check) between them. But all my objects are can be created dynamically at runtime. So i dont know how to make these object interact between each other. All clones are having the same script so how can they know when something other besides them is selected.

Thanks.

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

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Uriel_96 · Dec 31, 2010 at 08:22 PM

you may see this answer: http://answers.unity3d.com/questions/28251/how-to-perform-a-mouse-click-on-game-object/28252#28252 and you only change where it says the tag to a different color. Like this:

renderer.material.color = Color.red;
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 bionicnacho · Feb 04, 2013 at 02:55 AM 0
Share

404 on that page :/

avatar image
1

Answer by Jaap Kreijkamp · Jan 01, 2011 at 02:22 AM

If they share the same script you can share state using static variables. In Javascript static var someGlobal and in C# public static TypeName someGlobal

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
avatar image
0
Wiki

Answer by DryTear · Feb 04, 2013 at 03:13 AM

Attached to a Cube with a collider

var customColor : Color;

OnMouseEnter(){

   renderer.material.color = customColor;

}

OnMouseExit(){

  renderer.material.color = Color.white;

}

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

2 People are following this question.

avatar image avatar image

Related Questions

How do I revert prefab instance properties to their defaults? 0 Answers

How can i transfer an object from scene1 and instantiate it in scene2? 2 Answers

How can I Instantiate an Object from a Randomly Selected Index in an Array of Game Objects? 1 Answer

Destroy The Same Objects Before Instantiating 2 Answers

I made this script to instantiate objects, but when the game starts I get this error:IndexOutOfRangeException: Array index is out of range. 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