Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 Mr_FJ · Aug 20, 2015 at 04:55 PM · uibuttoncanvasevent3d model

Using a 3D model as a button, in Unity's UI system?

I have a 3D model, that is a child of a world space Canvas. How can I make it interactable, using the UI system? So far I've tried adding the button component, in addition to a box collider. I've also tried making it a child of a button prefab. No luck, am I missing something, or is it simply not possible, without using an event in a custom script?


2019 edit: Here's what I ended up creating and using back in 2016/2017:

https://www.dropbox.com/s/quf95uiwoijg50f/ColliderEventTrigger.unitypackage?dl=0

It has been tested in, and update for, 2019.1

Comment
Add comment · Show 2
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 Cherno · Aug 20, 2015 at 05:10 PM 0
Share

Why not just check if it is clicked via raycasting and if yes, call the button function directly?

avatar image Mr_FJ · Aug 20, 2015 at 06:01 PM 0
Share

That is one way to do it, I would just prefer to use the UI system, if possible. I find it's a lot faster and easier to use, than scripting my entire UI. Also it interacts more smoothly with the animation system.

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by KillerFirefly · May 09, 2019 at 03:18 PM

You can use a UnityEvent to get the nice pretty editor event system just like a Button component.

 using UnityEngine.Events;
 
 [RequireComponent(typeof(Collider))] //A collider is needed to receive clicks
 public class Interact : MonoBehaviour {

     public UnityEvent interactEvent;

     private void OnMouseDown() {
         interactEvent.Invoke();
     }
 }
Comment
Add comment · Show 2 · 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 TreyH · May 09, 2019 at 03:25 PM 0
Share

Although OP did want to avoid a "custom script", this is a pretty clean way of doing it.


I'm not following their aversion to writing something, as extending functionality of built-in Unity systems (like using a 3D object as a UI element) is the textbook use case for writing your own components.

avatar image Mr_FJ · May 10, 2019 at 08:33 AM 0
Share

I guess since you resurrected a 4 year old post anyway, I'll share what I ended up creating and using back then. It' might be missing some features added in 2018, but it works:

https://www.dropbox.com/s/quf95uiwoijg50f/ColliderEventTrigger.unitypackage?dl=0

avatar image
0

Answer by Noxury · Aug 20, 2015 at 05:12 PM

If you want to display 3D elements in the canvas combined with buttons, you can find a tutorial here.

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 Mr_FJ · Aug 20, 2015 at 06:00 PM 0
Share

Not what I'm looking for. The point/plan/idea is to use the "new" UI system.

avatar image
0

Answer by Nirvana33 · Aug 20, 2015 at 06:11 PM

You can use the OnMouseDown() function. Add it to your 3D model, and set the object child of the canvas.

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 Mr_FJ · Aug 20, 2015 at 08:20 PM 0
Share

But I would not be able to use the in editor event system then. I would have to do it all in a script, right?

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

32 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 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

Unity UI 4.6 Canvas Enable/Disable make Accessible 2 Answers

Changing button positions on different resolutions 1 Answer

How do Pointer events work? 4.6 UI 1 Answer

I Have a Button in Canvas, i Click anywhere except the button and it gets clicked 0 Answers

Event system or UI Button ? 0 Answers


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