Outline Object on Pointer Hover and Selection at Runtime in Unity

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video we will learn how to outline game objects on pointer hover and selection at runtime in unity if I my most hover over the game objects you see they get outline and if I click on one it will be selected and if you click on something else the other thing will be selected and if I want to deselect I'll just click outside and the game object will be deselected in my Unity editor I have a number of 3D game object here and materials assigned to them and for the outline effect we are going to use an F3 asset from the unity asset store name Quick Outline by Chris nolay and what you need to do is just to click it the asset is free just click add to my assets and then once that is done click open in unity then in unity editor go to window package manager and then make sure you scroll into uh packages my assets over here and look for the quick outline assets foreign so the quick outline I said would be here and then click uh download if if if if the option is available and once it's that it's done click import and then make sure everything is selected or press all and then click import once the import is done you will notice that under my assets folder we will have a new folder for the new assets called quit a quick outline so I'll just select it and go to their resources materials and select the outline fill and then choose the color for the outline that your desire in my case I will select something like magenta color maybe eight two five five over here that's the color I'm after and for the outline width I'll select for my K7 but feel free to change that based on your preference next we will add a tag name to the game objects that you want to be selectable for example in this case I don't want the plane to be selectable so I won't add attack to it so I'll just select one game object then and under the tag scroll down and add tag and click the plus button and we'll write select table with capital c s sorry and save and then select all the game objects I want to be selectable that's all everything but the plane and I will add the tag to them and they're selectable here and that's done now I'll need to create the script so under the assets folder I'll create create a select create folder and we'll name it Scripts and inside the script folder right click create C sharp file and we'll call it outline selection once the script file is created I'll just create an empty game object here to attach the script to it create empty call it the same outline selection and then I'll drag and drop the script into it and select it to make sure the script is there and then double click on the script file to open it in Visual Studio inside the scripts I added lines to control the highlight and selection and I put a link in the description to the GitHub place where you could download the the code from there so this is the code and then once that is done I'll save and then go back to the editor and inside the editor make sure the event system is there imported because the code requires it so right click UI and select event system and that's it so if I click play to run the code I'll change the display sorry to the from a free aspect to full HD and then if I uh my most hover over the game objects you see they get outline and if I click on one it will be selected and if you click on something else the other thing will be selected and if I want to deselect I'll just click outside and the game object will be deselected that's it thank you please like subscribe and click the notifications button to help me make more videos like this
Info
Channel: DA LAB
Views: 21,721
Rating: undefined out of 5
Keywords: Unity, Script, Model, C#, Pointer, Mouse, hover, Highlight, Select
Id: qYnAkMGbgwo
Channel Id: undefined
Length: 5min 8sec (308 seconds)
Published: Tue Jan 31 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.