My Favorite way to Click on GameObjects

  Рет қаралды 40,937

Andrew

Andrew

Жыл бұрын

Howdy, Howdy, Howdy! It's time for a quick video on Clicking GameObjects. This is a common but sometimes difficult thing to do in your Unity Project.
Documentation:
docs.unity3d.com/Packages/com...
Resources:
www.vecteezy.com/free-vector/...
Subscribe for future projects:
kzfaq.info...
Support my work, and get access to other projects!
/ vrwithandrew
Use this referral if you'd like to support me via the Unity Asset Store!
assetstore.unity.com/top-asse...

Пікірлер: 38
@Miss-ex1gnt
@Miss-ex1gnt 9 ай бұрын
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
@danilocolassoo
@danilocolassoo Жыл бұрын
That's a really good Interactable objects approach! Specially combined with UnityEvent
@AndrewMakingAnything
@AndrewMakingAnything Жыл бұрын
Thank you, and exactly! It's incredibly versatile.
@smirelesz
@smirelesz 8 ай бұрын
Great video. Elegant solution. Thank you!
@sissond
@sissond Жыл бұрын
I needed this like 11 months ago ;) Might go back and make that functionality more elegant
@AndrewMakingAnything
@AndrewMakingAnything Жыл бұрын
I'll know for next time! :)
@user-uq5li3wc4y
@user-uq5li3wc4y Жыл бұрын
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!
@prhc
@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
@indikaWijesooriya
@indikaWijesooriya Жыл бұрын
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
@AndrewMakingAnything
@AndrewMakingAnything Жыл бұрын
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.
@adfs774
@adfs774 Жыл бұрын
This is so much better than using annoying raycasting. Thx so much!!1
@sakeb1
@sakeb1 Ай бұрын
3:47: go to definition, best thing I learned here woah
@ritori3556
@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
@AndrewMakingAnything
@AndrewMakingAnything Жыл бұрын
It's just a simple example script and not necessary for the implementation. You can easily just put debug statements instead.
@ImKyleConway
@ImKyleConway Күн бұрын
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?
@zuban1988
@zuban1988 7 ай бұрын
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.
@rd88ify
@rd88ify 4 ай бұрын
Thanks! This resolved my issue. In my case I had to add a Box collider to my 3D game object
@ms.awesome
@ms.awesome 10 ай бұрын
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?
@AndrewMakingAnything
@AndrewMakingAnything 10 ай бұрын
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.
@mast1665
@mast1665 11 ай бұрын
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.
@AndrewMakingAnything
@AndrewMakingAnything 11 ай бұрын
Not exactly! However, feel free to join the Discord, and we'll see if we can figure it out.
@mast1665
@mast1665 11 ай бұрын
@@AndrewMakingAnything I had to use a box collider! Today was a learn intensive day. Thank you :)
@Snoopie_versus
@Snoopie_versus Жыл бұрын
How can I
@tahirdevlog2047
@tahirdevlog2047 6 ай бұрын
thank you
@AndrewMakingAnything
@AndrewMakingAnything 6 ай бұрын
Happy to help
@Arsen592_Old
@Arsen592_Old Жыл бұрын
Strange but I don't have Input System UI Input Module in my EventSystem, and I can't add it
@AndrewMakingAnything
@AndrewMakingAnything Жыл бұрын
Do you have the Input System Package installed?
@Arsen592_Old
@Arsen592_Old Жыл бұрын
@@AndrewMakingAnything oh I didn't input it, thanks
@AgalyAbdyev
@AgalyAbdyev Жыл бұрын
sorry but i have error on MaterialApplier. How to solve ?
@AndrewMakingAnything
@AndrewMakingAnything Жыл бұрын
That's just an example script. You can have a print statement there instead.
@DexterCrappell
@DexterCrappell 6 ай бұрын
@@AndrewMakingAnything I just started with unity, how would I add the print statement?
@AndrewMakingAnything
@AndrewMakingAnything 6 ай бұрын
@@DexterCrappell Within the click functions, you can write... print("Click"); or print("Hover"); Depending upon what the pointer event is
@appleseedgames6934
@appleseedgames6934 10 ай бұрын
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
@appleseedgames6934 10 ай бұрын
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
@ashwinsuresh1476
@ashwinsuresh1476 Жыл бұрын
andrew tate , top g
I Made the Same Game in 8 Engines
12:34
Emeral
Рет қаралды 3,9 МЛН
The Power of Scriptable Objects as Middle-Men
17:41
samyam
Рет қаралды 118 М.
Smart Sigma Kid #funny #sigma #comedy
00:25
CRAZY GREAPA
Рет қаралды 13 МЛН
Clicking on a 3D object (Unity/C# tutorial)
9:44
Mina Pêcheux
Рет қаралды 17 М.
World’s Deadliest Obstacle Course!
28:25
MrBeast
Рет қаралды 155 МЛН
Unity Mouse Click On GameObject || Unity 3D Tutorial / Touch
2:38
Coding Land
Рет қаралды 3,1 М.
Unity Tutorial | Clicking and Dragging 2D Sprites
11:00
3 Hours vs. 3 Years of Blender
17:44
Isto Inc.
Рет қаралды 4 МЛН
Making a COZY Monster Raiser in Scratch
5:24
Goodgis
Рет қаралды 669 М.
10 Things You NEED to Be Doing in Unity
11:40
Tarodev
Рет қаралды 127 М.
How To Use Scriptable Objects in Unity
4:28
Game Dev Guide
Рет қаралды 108 М.