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 Mikey923 · May 06, 2015 at 01:28 AM · menuwindowbitmap

How to display corresponding graphic when objects are clicked?

I'm new to Unity.

I've developed a 3D model of a pressure vessel and imported it into Unity3D. All the pieces are named accordingly and uniquely in my hierarchy ("nozzle_1", "coupling_2" etc.).

I have also created multiple .png graphics which relate to each part of the equipment. Each part of the equipment has at least two graphics that relate to it.

My goal is to make it so a user can walk around the pressure vessel, and when they click on each nozzle or coupling, a 2D GUI appears. It is just the graphic that applies to that particular nozzle, a button which can togle to show the second graphic relating to the nozzle, and a close button to remove the graphics from the screen.

I currently have my character controller set up so I can walk around my model in the scene, but I don't know where to start for the rest of the functionality.

Tank model: alt text

And when each nozzle is clicked on, I'd like to display a graphic like this. Overlayed on the screen, and no controls work until the user closes the window. And there would be a button to show a second graphic related to that nozzle, and a close button: alt text

Any help as to where I can start would be appreciated.

  • Is this considered a GUI texture? Since I have so many graphics, should I be using an array, and running a function with a loop to load the corresponding graphic, or add a unique script to each object?

Thanks in advance!

tank.jpg (124.1 kB)
fwk-n9.png (498.4 kB)
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by toddisarockstar · May 06, 2015 at 02:27 AM

well your going too need to figure the specifics yourself. sounds like a lots of lines of script you will have to right to get it to do all this, but i will get you started. first of all, you will need seperate colliders attached to all the gameobject's CHILDREN in the hierarcy to detect your object parts individually.

then you can use a mouse position raycast to figure out what part your user has clicked on.

eventually using arrays is going to make your life easier but here is a simple way to get buttons going when clicking on stuff.

 var gobuttons:int;
 
 var yerdisplay:Texture;
 var yerpicture1:Texture;
 var yerpicture2:Texture;
 
 function OnGUI(){
 
 if(gobuttons>0){
 
 GUI.DrawTexture(Rect(5,5,200,200), yerdisplay);
 if(GUI.Button  (Rect (300,300,50,50),"make yer buttons go away")){gobuttons=0;}}}
 
 
 function Update(){
 
 var clickray = Camera.main.ScreenPointToRay (Input.mousePosition);
         
         var hit:RaycastHit;
         
         if (Physics.Raycast(clickray, hit)) {
                 if(hit.collider.gameObject.transform.name.Contains("thingypart1"))
                       {yerdisplay=yerpicture1;gobuttons=1;}
            
 
                 if(hit.collider.gameObject.transform.name.Contains("thingypart2"))
                       {yerdisplay=yerpicture2;gobuttons=2;}}}

of course you would need to drag and drop your textures into the texture slots in the inspector and make the object names in the script match the real object names.

this will display a texture depending on what you click.hopefully you can add to it! good luck!

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Panel vs. Window for Menues 0 Answers

Editor Menu Item open Window 2 Answers

Activate function when GUI.Window is drag into area 0 Answers

MenuItem in EditorWindow 1 Answer

How to add a menu item to the window's right side pop-up? 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