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 redteardrop · Sep 14, 2012 at 08:24 PM · gameobjecttexturemouse position

using specific parts of objects as buttons?

I have a computer monitor in my game and want to use onscreen buttons. At the moment the only way I can think of is to have another object in front of the screen with the same texture and have the button script attached to each of these buttons. What I want is to be able to click directly on the monitor and tell what I clicked on. In the end I want the screen to be able to change or scroll and have the buttons still work. My idea was using a visible texture map for what the player sees and a secondary one that the engine could check if the mouse is over, that way I could use some sort of tracing function to check what color I am over and execute the appropriate button function. It would be nice to be able to change the hover and click texture too (I can do that no problem with the separate object method, but can't scroll the screen or have it just flip to a new screen. Plus it means I have to model each button and it's UV coordinates)

here is what I was thinking, but would need some help getting it running.

alt textalt text

as you can see one is just normal buttons, the other has a separate color layout for each one so that leaves a possible 16+ million buttons of any shape. (even using a single alpha map on a non transparent material would still work if it could detect what gray level is used for 256 possible buttons (not that I plan on using anywhere near that many). Please let me know if you can give me some idea how to do this thanks.

sample22b.jpg (29.4 kB)
sample22a.jpg (22.7 kB)
Comment
Add comment · Show 4
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 wilco64256 · Sep 14, 2012 at 09:12 PM 0
Share

Are you setting your monitor up as a GUI? If so you can make the elements directly clickable without having to duplicate them or make it more difficult to handle as a bunch of 3D objects. Otherwise I might just put small nontextured invisible planes with colliders right on top of each button to catch the clicks.

avatar image reptilebeats · Sep 14, 2012 at 11:31 PM 0
Share

just put box colliders in front of them and draw a ray to test for a hit on each collder

avatar image Outlaw Lemur · Sep 15, 2012 at 12:45 AM 0
Share

$$anonymous$$aybe you could use GUI.Button()?

avatar image redteardrop · Sep 15, 2012 at 04:56 AM 0
Share

Ok, if it's possible I guess I would update my question to be "How do I use a GUI.button on a GameObject?" adding a plane or collider in front of the button is what I am currently doing, but to make it work like a real monitor that changes screens I would need to make many button objects, code them all and obstantiate and destroy them based on what screen is currently visible. It's doable, but a pain as well as time and processor intensive compared to trying to do a hit test for a specific color on (as example) texture[2] of an object while displaying texture[1] if I apply a texture array to the object. I found hit test for if it's within a defined box on the texture uv map, but that only seems to be for a GUI element (GUILayer.HitTest). I suppose I could write it to use HitTest if I could use it on a texture of a gameobject and combine it to check what screen is currently up, but it doesn't seem to have any use but as a GUI element (as far as the docs say anyway)

1 Reply

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

Answer by Bunny83 · Sep 15, 2012 at 03:23 PM

So basically you want to do something like this:

http://answers.unity3d.com/questions/289506/how-to-do-a-selectable-map.html

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 redteardrop · Sep 17, 2012 at 03:39 AM 0
Share

Exactly what I need. The code I was using though didn't work. I apparently didn't realize I needed the raytrace code attached to the camera and the GetPixel code on my monitor screen.

thanks

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

14 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

Related Questions

Problem with texture to reset and re-enter the same texture 0 Answers

arrays / textures help 1 Answer

Can see 3D object through itself 0 Answers

How to make emissive maps glow? 2 Answers

How to change the textures of assigned gameobjects? 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