Unity3d AR Foundation - How To Block AR Raycast From UI Touch Events? (For ARCore And ARKIT)

  Рет қаралды 12,665

Dilmer Valecillos

4 жыл бұрын

Today I provide you with a demo on how to block touch events from instantiating AR objects when touch events collide with UI components. This video also shows you how to create a C# extension from a Vector2 which extends its functionality and adds a new method to check for UI collisions.
Get the AR Foundation demo shown in this video at:
github.com/dilmerv/UnityARBlockARRaycast
*** Support me by Subscribing to the channel as it will help me in bringing a lot more content ***
bit.ly/2NmnFMu
Support me in Patreon so I can keep doing stuff like this for free!
www.patreon.com/dilmerv
Get realtime indie development tips from me in Twitter
dilmerv
Subscribe to my indie development videos & game releases newsletter
www.dilmergames.com
Blog about Indie development and startup
www.dilmergames.com/blog

Пікірлер: 29
@LucasonGuitarz
@LucasonGuitarz 4 жыл бұрын
Thank you so much!
@jinggo7080
@jinggo7080 3 жыл бұрын
Awesome! It solved my problem perfectly. Thank you so much!
@dilmerv
@dilmerv 3 жыл бұрын
Cool I am glad this worked for you ! Thanks for the feedback
@sarangborude8260
@sarangborude8260 3 жыл бұрын
Thanks Dilmer, you are the best!!!
@dilmerv
@dilmerv 3 жыл бұрын
You are welcome and thanks for your nice feedback !
@leeben1082
@leeben1082 3 жыл бұрын
Very concise and useful :) Thank you !!!!!!!!!
@dilmerv
@dilmerv 3 жыл бұрын
Thank you Lee for your great feedback !
@lassardable
@lassardable 4 жыл бұрын
perfect as always. thank you!
@dilmerv
@dilmerv 4 жыл бұрын
You are very welcome thanks for your feedback !
@marcusmarcus4765
@marcusmarcus4765 3 жыл бұрын
@@dilmerv Please see comment by Richard Clarke: "Hi Dilmer. I'm struggling with one bit of this implementation, the code in the Vector2Extension. if (EventSystem.current.IsPointerOverGameObject()) { return false; } Surely every UI element is also a game object, so in testing mine always return ok to place. As its over a Canvas/Image or button gameObject? Did i miss something with this implementation. ?"
@bilbostabbins1882
@bilbostabbins1882 3 жыл бұрын
Hey Dilmer is there a way to detect the tag of the UI, so if the UI has some sort of tag like *Placeable* , users can still place Objects through that UI and if it has a tag like *Blocked* then they can't
@chris31911
@chris31911 4 жыл бұрын
Great content as ever, do you plan to do multiuser using AR Foundation? I think you mentioned it a couple months back, thanks!
@dilmerv
@dilmerv 4 жыл бұрын
Absolutely! I will bring it as soon as I finish a video on AR Foundation 4.0 which adds support to collaboration.
@dajoey2198
@dajoey2198 4 жыл бұрын
hello, I'm new to AR unity developing, is it possible to project an object to a tracked body? i've been messing a little bit with vuforia userdefinedtarget but it doesn't work too well for me. thank you!
@rsauchuck
@rsauchuck Жыл бұрын
Does this actually prevent the raycast from firing or does it just prevent the prefab from spawning? I need to be able to prevent the touch from creating the physics raycast in the first place.
@ryanlewis4148
@ryanlewis4148 3 жыл бұрын
Great video, how would I go about tweaking this so that it only places a single prefab rather than multplie.
@dilmerv
@dilmerv 3 жыл бұрын
You can change the implementation where you can save a reference to the previously placed game object and just check it the reference is null, if null then create it else don’t create it. Let me know if that makes sense.
@ryanlewis4148
@ryanlewis4148 3 жыл бұрын
@@dilmerv Thanks for the quick reply. Sorry it doesn't make sense to me due to my coding experience being next to 0 but i'm slowly learning by watching your videos.
@richardclarke1976
@richardclarke1976 4 жыл бұрын
Hi Dilmer. I'm struggling with one bit of this implementation, the code in the Vector2Extension. if (EventSystem.current.IsPointerOverGameObject()) { return false; } Surely every UI element is also a game object, so in testing mine always return ok to place. As its over a Canvas/Image or button gameObject? Did i miss something with this implementation. ?
@almasakchabayev3907
@almasakchabayev3907 3 жыл бұрын
You are correct, removing those lines made the script work for me
@Texellent
@Texellent 3 жыл бұрын
He didn't show us the event system he uses ..
@marcusmarcus4765
@marcusmarcus4765 3 жыл бұрын
thank you sir
@taoufiqsmail8727
@taoufiqsmail8727 2 жыл бұрын
Hello I am working on an augmented reality project and I want to know how to see my drawing in reality and which software should I use unity foundation or unity mars
@dilmerv
@dilmerv 2 жыл бұрын
You can use either of those solutions but I am sure that with Unity AR Foundation you can accomplish what you need.
@neilpryde60
@neilpryde60 4 жыл бұрын
Great and rare content ! However in your videos, your are often refering to "the previous video" and it is not easy to find which one is the previous. May be add a number in the title when needed for a serie on a particular topic.
@dilmerv
@dilmerv 4 жыл бұрын
mm you are super correct, I will improve this in future videos to make sure previous is defined in the description, thanks for your feedback !
@kamillatocha
@kamillatocha 3 жыл бұрын
i like it but the script spawns new objects every click and orginal could move object around the plane and removed old one so theres only 1 in scene
@kalita2127
@kalita2127 4 жыл бұрын
Cool tutorial! But that doesn't work on Canvas world
@corbinordel
@corbinordel 3 жыл бұрын
anyone able to see why this only works once? It will only block one raycast on the UI and only work again if the bool is set to false. Link to script: hatebin.com/lcphjqusaa
HOW DID HE WIN? 😱
00:33
Topper Guild
Рет қаралды 36 МЛН
HOW DID HE WIN? 😱
00:33
Topper Guild
Рет қаралды 36 МЛН