Do keep mindful of any objects that may block the raycast! I had a canvas with components that I animated out of my screen, but they kept on blocking the raycast. I added "deactivate raycast target" at the end of the animation and solved the "mystery". Still, I must admit, I have gone bonkers until I finally realized what it was! DX
@justcore695 ай бұрын
Your comment just saved a lot of my gamejam time. Thank you!
@Roadtotarget2 ай бұрын
Don't forget to add Box Collider component to your objects you want to click
@sakeb17 ай бұрын
3:47: go to definition, best thing I learned here woah
@emilyhorton996Ай бұрын
deserves way more views and thumbs ups. thank you so much!
@prhc Жыл бұрын
thanks for the video, when using this technique with UI toolkit in unity version 2021.3.24 i had the problem of not being able to select any game objects, only PanelSettings were being selected. i solved this by setting the picking mode of the root visual element to Ignore in the UI Builder
@sissond2 жыл бұрын
I needed this like 11 months ago ;) Might go back and make that functionality more elegant
@VRwithAndrew2 жыл бұрын
I'll know for next time! :)
@zuban1988 Жыл бұрын
Thank you! BTW, I had a problem with code generted mesh, it did not fire the events until you add collider (MeshCollider in my case), then it works.
@rd88ify10 ай бұрын
Thanks! This resolved my issue. In my case I had to add a Box collider to my 3D game object
@LetsFacetheMusicandDance3 ай бұрын
I had the exact same problem ... wish I saw this comment sooner : )
@ImKyleConway5 ай бұрын
I've set up the script and it works great, however I am trying to use this to inspect items but when I adjusted the main camera's near clipping plane, it no longer worked. Anyone know why?
@danilocolassoo Жыл бұрын
That's a really good Interactable objects approach! Specially combined with UnityEvent
@VRwithAndrew Жыл бұрын
Thank you, and exactly! It's incredibly versatile.
@ms.awesome Жыл бұрын
okay so im using Cursor.lockState = CursorLockMode.Locked; because my game is in first person but this prevents being able to click on the object like this! Any way to fix it or workaround it?
@VRwithAndrew Жыл бұрын
There's some code in the Event System that prevents events if the cursor is locked if I remember correctly. There isn't an easy workaround, but you may be able to copy the script into a new file and make the necessary edits.
@adfs774 Жыл бұрын
This is so much better than using annoying raycasting. Thx so much!!1
@froggothecommentator80364 ай бұрын
sorry but im having some problem with the clicking system rn. It keeps telling me that im having the error "CS0246:the type of namespace name... could not be found". Could you help me with this please?
@mast1665 Жыл бұрын
Are there any more resources on this? I just started my unity journey and cant quite get my head around this system. The Events seem to fire endlessly, not only when (for example) clicking on the GameObject I added this script too... No matter where I move/click the mouse. The script answers always.
@VRwithAndrew Жыл бұрын
Not exactly! However, feel free to join the Discord, and we'll see if we can figure it out.
@mast1665 Жыл бұрын
@@VRwithAndrew I had to use a box collider! Today was a learn intensive day. Thank you :)
@ritori3556 Жыл бұрын
Hi! Thank you for great tip! However, as a beginner, I suffered a lot in implementing it. Could you please share or show in your tutorial MaterialApplier script :( In trying to make it on my own, I got completely lost
@VRwithAndrew Жыл бұрын
It's just a simple example script and not necessary for the implementation. You can easily just put debug statements instead.
@smirelesz Жыл бұрын
Great video. Elegant solution. Thank you!
@marcoballan40674 ай бұрын
is there any way of implementig this with right clicks or does it only works with left clicks?
@VRwithAndrew4 ай бұрын
Yeah, you can use the PointerEventData with some code like this. public override void OnPointerClick(PointerEventData eventData) { if (eventData.button == PointerEventData.InputButton.Right) { // Your code } }
@AgalyAbdyev Жыл бұрын
sorry but i have error on MaterialApplier. How to solve ?
@VRwithAndrew Жыл бұрын
That's just an example script. You can have a print statement there instead.
@DexterCrappell11 ай бұрын
@@VRwithAndrew I just started with unity, how would I add the print statement?
@VRwithAndrew11 ай бұрын
@@DexterCrappell Within the click functions, you can write... print("Click"); or print("Hover"); Depending upon what the pointer event is
@ДосталиЕвский Жыл бұрын
Can you please clarify how to select an object using a gamepad controller? I'm currently in the process of setting up my input systems for the gamepad, but I'm unsure of how to accomplish this task. Thank you for your assistance!
@clamarpedАй бұрын
Great video, however, I would have loved it if you had explained how it would work with different objects with different actions, as I can't really see that function with how you show it in the example sadly.
@castlecodersltd4 ай бұрын
Very helpful, thank you 🙂
@VRwithAndrew4 ай бұрын
Happy to help!
@ClimFreeFeelRain Жыл бұрын
How can I
@Arsen592_Old Жыл бұрын
Strange but I don't have Input System UI Input Module in my EventSystem, and I can't add it
@VRwithAndrew Жыл бұрын
Do you have the Input System Package installed?
@Arsen592_Old Жыл бұрын
@@VRwithAndrew oh I didn't input it, thanks
@indikaWijesooriya2 жыл бұрын
This is a great tip Andrew!. Thanks. It's been a while :-) I'd also like to know your take on custom graphic raycasters. Eg: Projecting a UI to a curved object (probably with render texture) and getting the raycast input to convert to a UI input. Mainly in VR
@VRwithAndrew2 жыл бұрын
I haven't really created my own raycaster before. But, I'm pretty sure you can! I also have some experience with the Curved UI Asset. Technically, you may be able to use the existing Ray Interactor from XRI, a Custom Event System, and a visual element to bend the UI.
@martinjacobsen59743 ай бұрын
Yeah sorry. It's a super sweet video and very to the point. But as a beginner I have no idea what I'm looking at what is from unity and what you wrote ahead of time. I can see that it's a super straight forward system once it's set up but I needed the "setting it up from zero" Thanks for the video though.
@appleseedgames6934 Жыл бұрын
Thought this would really easy but magically it's not working, followed the tutorial the exact same and followed other issued people have had but it's just simply not returning a debug on click at all
@appleseedgames6934 Жыл бұрын
Solution: Cursor.lockState isn't compatible with it. Pretty making this entirely useful except for a handful of cases, don't waste your time with this
@tahirdevlog2047 Жыл бұрын
thank you
@VRwithAndrew11 ай бұрын
Happy to help
@Dan-ed1skАй бұрын
This is not really helpful, you don't provide enough info