I agree. Cool thing is that the channel has more than doubled subscribers in the last 30 days (according to SocialBlade), so people are noticing. Hopefully it keeps up.
If you get a "Can't add script error" it's because line 5 of the code after "public class" needs to be the same name as whatever the script is. This is my second day of unity and I renamed the script after I made it so the names didn't match. Awesome video, thanks for NOT including 10 minutes of fluffy BS.
Thank you so much for this video! I've learned so much in just the first half alone! This is my first step to building a game, and it feels really good to see something actually working when I press play!
If you get an error message like me that says "`Cursor' does not contain a definition for `SetCursor'" its because you named your script "Cursor". Was banging my head against the wall trying to figure it out. Dont be like me, name your script appropriately lmao
This is such a great and clear tutorial! I'm just wondering (as I am new to unity) if there's a way I can use this method to click my objects but also use the mouse to look around the environment also? Thank you for any help you can give :)
Awesome! Yes I have a follow up video for clicking ua-cam.com/video/JID7YaHAtKA/v-deo.html and I have a video on panning and zooming around the scene with cinemachine ua-cam.com/video/PsAbHoB85hM/v-deo.html And then if you want to bound your camera movement to a certain space here is another video ua-cam.com/video/izumXk-xoEM/v-deo.html Lots of videos 😂
When writing script, for start function, 7:47, controls.Mouse.Click.started, my script has error: “CursorControl does not contain a definition for “Mouse” . There was an option for MouseActionMap, are they the same ? How to fix this error?
Figured it out right as I left a comment! I was using my own naming for variables & such, User error! If you've done the same, check your input action naming. Name of variable you've set (control), Action Map name (mouse), and Action (Click). Control.mouse.click; If you use the default mapping that Unity makes, it'll be [your variable name].Player.click. Hope that helps~
32x32 texture for cursor is required, however according to this forum you can possibly resize the actual pixels of the texture: forum.unity.com/threads/cursor-size.288333/#:~:text=If%20you%20want%20to%20resize,is%20just%20taking%20up%20memory. Or you can ignore this method and have an empty gameobject with a sprite cursor and have that follow your mouse movement
i have been informed by unity that "'Texture2D' does not contain a definition for 'SetCursor' and no accessible extension method 'SetCursor' accepting a first argument of type 'Texture2D' could be found (are you missing a using directive or an assembly reference?)" can you provide assistance? would be appreciated
You could either take in another texture with the color you want or you'd have to change the color by going through each pixel of the texture 2d and changing the tint. gamedev.stackexchange.com/questions/124463/changing-some-color-of-a-texture-using-c-in-unity If you only have a mouse in your GUI you can apply a global GUI tint to change the color at that moment forum.unity.com/threads/dynamical-color-change-of-mouse-pointer.166366/
I show how to do a similar effect here: ua-cam.com/video/XUx_QlJpd0M/v-deo.html Basically add the trail renderer to a gameobject, then move the gameobject according to where the mouse is
hi, i was thinking of changing my project's implementation of inputs to 'input system', but is it worth it? I say, 'input system' is in version 1.0, so I imagine there will be annoying bugs, I saw the documentation but I do not realize the great advantages over doing it the 'traditional' way. What is your opinion at the time of practice, what 'great advantages' you see in 'input system'. Thanks, and very good videos, greetings!
so rotate around the y axis? In the update method you can call RotateAround similar to the example here docs.unity3d.com/ScriptReference/Transform.RotateAround.html
For using a mouse cursor in a menu system, would "release only" be suitable? I'm trying to create a mouse interaction that feels "natural" (at least in a menu to start)
Hm why would you want to do this? It’ll make the player feel as if they can’t move the mouse. To lock it in the middle you can use Cursor.lockState = CursorLockMode.Locked; And if you want something to show in the middle you can add a sprite to the center of the screen
Unfortunately, SetCursor is unusable for me. At first I thought I made a bug, but SetCursor simply does not change my cursor at times. I am not alone in this issue as people have stated this function to be unreliable for years. The OS wants to fight Unity for control.
That’s a little tricky it seems, you’ll have to simulate the mouse cursor if you lock it to see what UI it is over. You can also shoot raycasts and have the UI with colliders to detect if the ray hits the button. Here’s some threads that may help forum.unity.com/threads/world-space-canvas-cursorlockmode-locked-incompatible.566485/ forum.unity.com/threads/fake-mouse-position-in-4-6-ui-answered.283748/?_ga=2.160872958.255425762.1618484813-653284547.1617361468 stackoverflow.com/questions/38054706/alternative-of-raycast-for-ui-items-in-unity3d stackoverflow.com/questions/42384658/unity-ui-interacting-with-worldspace-ui-when-cursor-is-locked
Oh I had this problem last month! If you haven't solved it already, check your script name. If you named it Cursor, then it would be overriding Unity's Cursor class, causing the problem.
I changed this Input System and my whole Game crashed. Now reinstalling Unity and hope that I can fix this =/ but anyway I learned how to change my curser.
@@samyam yeah sure 😋, lesson learned. But I will see it as a second chance to start my game new with better codes and graphics. I was not that far with the game 🖖🏼
It has to do with your import settings on the image. Make sure it is set to Texture2D for type and you can adjust the compression and filtering as well
I tried this with a new 2d sprite, gave it type cursor , compression none, and set it as my cursor object's Cursor variable, and it didn't change my cursor.
Hi! In the console it throws me-> InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings. and is because i have in many sides -> Input.GetMouseButtonDown(0), so only solution is Setting Active Input Handling to "Both"?
This channel is so underrated. This is easily the best Unity tutorial channel for beginners on UA-cam.
Glad you like it :)!
I agree. Cool thing is that the channel has more than doubled subscribers in the last 30 days (according to SocialBlade), so people are noticing. Hopefully it keeps up.
Thank you! 😁
I love how she moves the mouse around the thing while explaining it. It shows a lot of enthusiasm about the topic.
Some people were complaining about it so I’ve stopped doing it as much in my more recent videos 🤣 Glad someone liked it!
Thanks! I have watched so many different videos and none of them worked, but this video was straight to the point.
If you get a "Can't add script error" it's because line 5 of the code after "public class" needs to be the same name as whatever the script is. This is my second day of unity and I renamed the script after I made it so the names didn't match. Awesome video, thanks for NOT including 10 minutes of fluffy BS.
Thank you so much for this video! I've learned so much in just the first half alone! This is my first step to building a game, and it feels really good to see something actually working when I press play!
This is the best tutorials I have seen for UNITY. Well done! And thank you so much for this great content.
Thank you!! 😄
If you get an error message like me that says "`Cursor' does not contain a definition for `SetCursor'" its because you named your script "Cursor". Was banging my head against the wall trying to figure it out. Dont be like me, name your script appropriately lmao
same here, but I named the input control "cursor"
I did neither of these and am having the same issue?
THANK YOU! this saved me, i was struggling! haha
Thank you so much I needed this type of tutorial =D
How do I make the cursor scale correctly with different resolutions? :(
Thank u so much for this video!!! It helps soooo much! You're really a good teacher!!!
Thank you so much!! Appreciate it 😁
The click doesnt work by me. There are no errors, but it just doesnt work! Any ideas why???
Thanks!
Thanks so much for the donation!! :D
Nice video!
I get this error code when I try this "Assets\Pixel Cursors\CursorController.cs(24,6): error CS1513: } expected"
This is such a great and clear tutorial! I'm just wondering (as I am new to unity) if there's a way I can use this method to click my objects but also use the mouse to look around the environment also? Thank you for any help you can give :)
Awesome! Yes I have a follow up video for clicking
ua-cam.com/video/JID7YaHAtKA/v-deo.html
and I have a video on panning and zooming around the scene with cinemachine
ua-cam.com/video/PsAbHoB85hM/v-deo.html
And then if you want to bound your camera movement to a certain space here is another video
ua-cam.com/video/izumXk-xoEM/v-deo.html
Lots of videos 😂
@@samyam Thank you so so much!
the buDIN, as opposed to button
When writing script, for start function, 7:47, controls.Mouse.Click.started, my script has error: “CursorControl does not contain a definition for “Mouse” . There was an option for MouseActionMap, are they the same ? How to fix this error?
I'm stuck at that part too :x
Figured it out right as I left a comment! I was using my own naming for variables & such, User error! If you've done the same, check your input action naming. Name of variable you've set (control), Action Map name (mouse), and Action (Click). Control.mouse.click; If you use the default mapping that Unity makes, it'll be [your variable name].Player.click. Hope that helps~
@@Klash120 i have the same problem, but I don't quite understand what do you mean 😅 can you try to explaine better? Thank you!
YAY! new video that explains stuff which l have no idea what is this :D
Nice video! May I ask if we can resize the cursor using script? Thanks.
32x32 texture for cursor is required, however according to this forum you can possibly resize the actual pixels of the texture:
forum.unity.com/threads/cursor-size.288333/#:~:text=If%20you%20want%20to%20resize,is%20just%20taking%20up%20memory.
Or you can ignore this method and have an empty gameobject with a sprite cursor and have that follow your mouse movement
@@samyam Thank you very much!
My imported cursor only appears once I hit escape. Any ideas?
i have been informed by unity that "'Texture2D' does not contain a definition for 'SetCursor' and no accessible extension method 'SetCursor' accepting a first argument of type 'Texture2D' could be found (are you missing a using directive or an assembly reference?)"
can you provide assistance? would be appreciated
Same issue, don't know how to fix it. Did you find a solution
i have not, i've since moved away from unity and toward gamemaker
Useful, thanks! If I can, how change (overlay) the color of cursor with c# script?
You could either take in another texture with the color you want or you'd have to change the color by going through each pixel of the texture 2d and changing the tint.
gamedev.stackexchange.com/questions/124463/changing-some-color-of-a-texture-using-c-in-unity
If you only have a mouse in your GUI you can apply a global GUI tint to change the color at that moment
forum.unity.com/threads/dynamical-color-change-of-mouse-pointer.166366/
@@samyam Thank you!
Please. how to add trail effect on mouse cursor?
I show how to do a similar effect here: ua-cam.com/video/XUx_QlJpd0M/v-deo.html
Basically add the trail renderer to a gameobject, then move the gameobject according to where the mouse is
hi, i was thinking of changing my project's implementation of inputs to 'input system', but is it worth it?
I say, 'input system' is in version 1.0, so I imagine there will be annoying bugs, I saw the documentation but I do not realize the great advantages over doing it the 'traditional' way.
What is your opinion at the time of practice, what 'great advantages' you see in 'input system'.
Thanks, and very good videos, greetings!
I recommend it, super simple to set up and you can easily change controls for different systems as well as allow multiple controls for one action.
silly question here but... how to make a 3D object automatically rotating like an idle state?
so rotate around the y axis? In the update method you can call RotateAround similar to the example here docs.unity3d.com/ScriptReference/Transform.RotateAround.html
@@samyam thank you! I knew it had to be easy! I'm just new to Unity ^_^
For using a mouse cursor in a menu system, would "release only" be suitable? I'm trying to create a mouse interaction that feels "natural" (at least in a menu to start)
Yes I think release would be suitable, you can always test or ask someone to test to see how it feels.
Honestly curious what color theme you're using for vs code here
I'm using the Godot color theme 😂
Can anyone help me? I'm trying to lock the cursor in the middle of the screen with having it stay visible, is there a way to do this?
Hm why would you want to do this? It’ll make the player feel as if they can’t move the mouse. To lock it in the middle you can use Cursor.lockState = CursorLockMode.Locked;
And if you want something to show in the middle you can add a sprite to the center of the screen
Unfortunately, SetCursor is unusable for me. At first I thought I made a bug, but SetCursor simply does not change my cursor at times. I am not alone in this issue as people have stated this function to be unreliable for years. The OS wants to fight Unity for control.
how to interact with world space ui in cursor lock mode
That’s a little tricky it seems, you’ll have to simulate the mouse cursor if you lock it to see what UI it is over. You can also shoot raycasts and have the UI with colliders to detect if the ray hits the button.
Here’s some threads that may help
forum.unity.com/threads/world-space-canvas-cursorlockmode-locked-incompatible.566485/
forum.unity.com/threads/fake-mouse-position-in-4-6-ui-answered.283748/?_ga=2.160872958.255425762.1618484813-653284547.1617361468
stackoverflow.com/questions/38054706/alternative-of-raycast-for-ui-items-in-unity3d
stackoverflow.com/questions/42384658/unity-ui-interacting-with-worldspace-ui-when-cursor-is-locked
@@samyam thank you so much for your suggestions ✌🏻😇
Unity says I have no definition for "SetCursor" or "lockState"
can you help out or let me have a finished scripted (my code barely comes out right)
Make sure you are putting Cursor.SetCursor and Cursor.lockState. The code is available for patrons in the description.
Oh I had this problem last month! If you haven't solved it already, check your script name. If you named it Cursor, then it would be overriding Unity's Cursor class, causing the problem.
@@HadiExtreme It was the excatly problem I had... thx!
I changed this Input System and my whole Game crashed. Now reinstalling Unity and hope that I can fix this =/ but anyway I learned how to change my curser.
😅 remember to back up your project!
@@samyam yeah sure 😋, lesson learned. But I will see it as a second chance to start my game new with better codes and graphics. I was not that far with the game 🖖🏼
My cursor is only pixels or a disstroted image. Any idea why?
It has to do with your import settings on the image. Make sure it is set to Texture2D for type and you can adjust the compression and filtering as well
I tried this with a new 2d sprite, gave it type cursor , compression none, and set it as my cursor object's Cursor variable, and it didn't change my cursor.
Did you make sure to attach the script to a gameobject? Also try calling the SetCursor in the Start method instead to see if that helps.
controls.Enable(); and Disable() throws a NullReferenceException
Did you instantiate the controls?
controls = new CursorControls();
@@samyam ok that helped :D
I tried again with the Kenny assets and still nothing.
I just got it to work by restarting Unity. Does that mean Unity bugged out?
Maybe! Sometimes restarting fixes bugs and some issues
Hi!
In the console it throws me->
InvalidOperationException: You are trying to read Input using the UnityEngine.Input class, but you have switched active Input handling to Input System package in Player Settings.
and is because i have in many sides -> Input.GetMouseButtonDown(0), so only solution is Setting Active Input Handling to "Both"?
Yes you should only be using the new input system if you enabled it, but you can switch to both to disable the errors
why does unity change the way their code works every 2 seconds? this tutorial doesn't work anymore
What do you mean? It should work. What issue are you having?
It really feels like the video went way too fast. It was really hard to keep up, even with having to pause the video
Sorry about that! I’ve been improving my pacing and speed in my more recent videos. Thanks for pointing it out!
finally smthn useful
why you circling mouse cursor? too annoying
Yeah I know I need to work on that 😅 I don’t notice when I record