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 bobmoff · Mar 08, 2015 at 07:01 PM · eventsystemcollider 2devent-handling

How to pass a pointerclick event on to the next collider ?

I have multiple 2d box colliders on top of each other. I use the iPointerClickHandler interface to intercept the click and this works fine. The object that is render on top of the other will receive the OnPointerClick call.

But my question is then, can I ignore, or when I am finished with the event let the next Collider in line to have it instead ?

I am trying to create a debug mode in a game so that on top of every click that happens I want to display some information about the current action that was taken, and this includes clicking on things that dont have any regular effect inside the game.

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 slake_it · Sep 25, 2015 at 07:57 AM 0
Share

any one have a solution for this ?

avatar image bobmoff · Sep 25, 2015 at 09:08 AM 0
Share

I solved it by making my own touch handling using raycasting.

2 Replies

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

Answer by slake_it · Sep 26, 2015 at 05:55 PM

@seth_slax i think you can use Physics.RaycastAll to get all the intercepted objects instead of performing a raycast multiple times, however, i don't know what is the order they are retrieved in.

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 seth_slax · Sep 26, 2015 at 11:35 PM 0
Share

Totally forgot RaycastAll existed @slake_it, haha. If the order was out, you could simply sort it based on Vector3.Distance of the raycast origin.

avatar image
0

Answer by seth_slax · Sep 25, 2015 at 09:38 AM

Just change the LayerMask of the clicked object to the IgnoreRaycast layer in code, or create your own custom RayMask and switch to that.

Comment
Add comment · Show 3 · 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 bobmoff · Sep 25, 2015 at 11:19 AM 0
Share

What I wanted was a way to decide in code WHEN clicked if the collider should "sawllow" the click or pass it along so that the click could actually pass through all the colliders that was hit.

avatar image seth_slax bobmoff · Sep 25, 2015 at 11:37 AM 0
Share

I don't think there's a way to recieve a raycast and continue it along. The only alternatives I can think of would be (psuedocode):

  • Fire raycast.

  • Object hit decides to absorb or ignore.

  • If ignore, call another raycast from the original source.

  • Repeat for each collider (or just have duplicate scripts).

Or:

  • Fire raycast.

  • Object hit decides to absorb or ignore.

  • If ignore, switch layermask to IgnoreRaycast.

  • Fire a raycast from the hit.point of the collider onwards.

  • Repeat accordingly.

avatar image bobmoff seth_slax · Sep 25, 2015 at 02:52 PM 0
Share

I ended up using the

public static RaycastHit[] RaycastAll(Ray ray, float maxDistance = $$anonymous$$athf.Infinity, int layer$$anonymous$$ask = DefaultRaycastLayers, QueryTriggerInteraction queryTriggerInteraction = QueryTriggerInteraction.UseGlobal);

that fills an array of all the hits that I could use the way I needed.

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

23 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

Related Questions

Unity 2019.3 any way to make mouse events pass thru an UI element without disabling "Raycast Target" ? 2 Answers

Looking for a way to avoid using Update() Function 0 Answers

Event.current.Use() not consuming event in editor SceneView 1 Answer

Help, Use event system IPointerClickHandler 1 Answer

UnityEngine.EventSystems.. Trying to figure it out .js 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