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
2
Question by JoaoPaul54 · Sep 03, 2014 at 05:05 PM · ui

uGUI Button with collider bigger than sprite

Like written in the title. Is there any way to create an uGUI button with a collision area bigger than the sprite? I am using unity 4.6 beta v18 I explored the possibility of scripting the collision area but due to the way IsRaycastLocationValid works its not possible (obviously) to detect something beyond the borders of the sprite.

Is there any method that can help me that I don't know of?

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
3

Answer by kjuanlu · Oct 14, 2014 at 12:59 PM

I just tryed this and worked for me:

-Add this scrip:

    #pragma strict
     
     @script ExecuteInEditMode()
     public class SimpleGraphic extends UI.Graphic{
     
     
         protected function OnFillVBO (vbo : List.<UIVertex> ){
             
         }
     }

  • -Crate a UI.Image (this will be renderer as button)

  • -Create a UI.Button (this will be invisible)

  • -Remove the UI.Image from the button, and add the new SimpleGraphic component

  • -Set Target Graphic to the UI.Image gameObject

You can manipulate the size of both gameObjects independently.

I checked that the new SimpleGraphic component has no drawcall costs (no vertex, no tris)

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 gfoot · Mar 20, 2015 at 10:15 PM 0
Share

This works really well, thank you.

avatar image TimB · Jun 14, 2015 at 07:26 PM 0
Share

Works great, Thanks!

C#:

 [ExecuteInEdit$$anonymous$$ode]
 public class SimpleGraphic : UnityEngine.UI.Graphic
 {
     protected override void OnFillVBO(System.Collections.Generic.List<UIVertex> vbo)
     {
         
     }
 }
avatar image
0

Answer by AyAMrau · Sep 03, 2014 at 10:11 PM

Unfortunately it doesn't look like there is a easy and clean solution for this.

The quick solution: You can make invisible buttons with transparent sprites (or normal sprites but the color alpha set to 0), it's rather hacky, but does the job.

The clean solution: Make your own class extending the BaseRaycaster and come up with your own way of doing this.

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

uGUI: Choose parent for anchors 0 Answers

uGUI text field set focus 0 Answers

Content Size Fitter and Anchors / UI Scaling? 2 Answers

[Unity 4.6 uGUI] Using uGUI and unity built in sprite packer does not reduce draw calls. 0 Answers

Applying materials to the new UI elements (4.6) 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