10 Things You Should Know in Unity

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hey what's up Jason here again when I started using unity back a long time ago I had to learn through books I had to buy some books and try to read the text and look at some really weird little screenshots and figure out how to use the editor and it worked kind of but I really struggled figuring out all of the important parts of unity and all the things that I needed to know I knew what was in the book but not everything that was well really important so in this video I want to give you just a quick walkthrough of some of the most important parts of the unity editor so what those different parts are and how you can use them now if you're a really experienced unity developer you probably see in most of these but I have met plenty of professional unity developers out there who didn't know them all so stay tuned and see if you learned something the first and probably the most important part of unity is the project view that's this window right down here that shows all of the files that are actually in your project this includes your code and your art and it maps directly to a folder on your system so if I go right click and hit show and Explorer you'll see that it actually opens up the folder right here and this assets folder matches up exactly with what we see in the project view so this is where you will store all your files you can drop files in there you can browse to them and pull them out and move them around just like a normal file structure the next most important part of the editor is the scene hierarchy this shows us everything that's currently in our level or multiple levels because we can show multiple levels in here it shows us we have a camera and a directional light that we can select we can also drag things from our project view right up into the hierarchy to add them to our level we can duplicate these objects and parent them or delete them back out the scene view shows us a visual representation of everything that's in our level while we can select objects in our scene hierarchy we can actually see them and move them around in the scene view I can just click on them and grab the little tool here to move them scale them rotate them or whatever I can also hold down the right mouse button to look around and use W a s and D while I'm holding it to move just like a normal first-person shooter and if I hold shift its prints the asset store is another really important part in unity I'd say it's probably one of the things that made unity such an amazing engine because there are so many art assets and code assets that you can just pull into your projects and use for cheap or even free for this one I wanted to pull in a character I need a nice 2d character that we can do some work with so I search for characters go to price drag that price slider all the way down to free and pull in this night sprite sheet so just click on it and hit import pull the sucker right in now I wanted to point out that while art assets are a huge huge part of the asset store they're not everything there are some other really cool assets out there like Odin inspector one of my favorites so I definitely recommend you go through and check them out if you're not familiar with the asset store yet but watch out it can be a bit of a money pit you can get addicted and just start buying assets after assets after assets I've done it myself and I have a couple friends who have way too many that we never even use but like I said it's awesome definitely check it out the next thing I want to show is the built in animation window if you go to window animation and then animation not to be confused with animator and click the button you'll get a window that looks like this and you may notice that it says to begin animating this Knight attack o1 create an animation clip so just have to hit the create button and then I need to give it a folder and a name so this is an attack animation its name it attack now to get animations in here I'm gonna move my project view for a moment and then I want to go into this night PNG folder and take a look at all of the different sprites if I select them you'll see them showing up right there down in the corner showing this animation off now if I want to make my own animation I can do this really easily I can just select all of these and drop them right in here and hit play now I've got an animation that's playing if I want to slow this down I can just grab this little dot at the end kind of expand out the animation there we go and now it's a bit slower of an animation I probably don't want a full second though this seems like something that would go at about a quarter of a second and it's worth noting that this is in seconds or not really in seconds one is one second but notice that it goes up by sixtieths of a second and not hundredths of a second so we go to 55 and then one second now I want to show you the animator component but before we do that we need to make a second animation so to do that I just go right here click this button and hit create new clip and we're gonna make an idle animation and again just take all of the idle sprites right here drop them right down here expand this out a little bit and hit play there we go we've got an idle animation and an attack animation already created from our sprites in just a couple of seconds so let's take a look at the next thing next I want to show the animator when we created an animation in the last section it actually added an animator and an animator controller if I double-click on this controller it opens up the animator window you can also get to this through window animation and animator that's the one I was saying watch out for and if we look here you'll see that it's got an entry point and an attack and an idle these are all of the animations that we've created with this character we couldn't of course add other animations later but we just need these too so I'm gonna show you how to navigate this thing real quick first you want to hold down alt and click on this back canvas area and just drag around that's how you move your view of this animator window now I want idle to be the default animation so I select idle right click and hit set as layer default stayed so now what will happen is if I hit play my little knight is gonna play his animation in fact let's watch it and there you see the game view another awesome part of the editor so he's playing as animation looks good now if I go back to my animator window I have this attack animation as well so let's delete the attackee animation and then re-add it just by dragging it right back up here again didn't change anything just wanted to show that that's how we add them in so what do we do with this state machine this animator or this mechanism system well we can go to this idle and right click and hit make transition and it gives us a little arrow there I can move around and I can drop it onto attack then I can select this little line that was created and add a condition but I don't have a way to set up a condition quite yet because I haven't created parameter so to set up a parameter I go up to this layers and parameters section these are actually tabs I know that's kind of hard to tell but I go select the parameters tab hit plus and maybe add a bool and call it attack the capital a there then my conditions will allow me to select attack I hit plus and it automatically selected attack because that's the only option and it automatically selected true because that's the default so when attack is true it'll go from idle to attack and then I can go to attack just select it right-click make transition back to idle select that transition the one with the arrow going towards idle add another condition and set attack equals to false then if I hit play you'll see that I can switch instantly between these two animations so let's drag the animator window down there and just click the attack there we go and if I unclick it it stops attacking the next thing I want to show you has to do with UI elements so imagine you're putting a button into your game and you want to resize it notice how things start to get a little bit weird and it stretches out this is actually really easy to fix but a lot of people don't know about this one little tool the sprite editor so if I select my sprite asset down here in the project view and it is set to be a sprite I can hit the sprite editor and pop open this nice little sprite editing window that's let's line this up and I'm gonna show you exactly how to use it it's really simple so what we need to do is slice this sprite up so that only the part that's repeatable or stretchable is inside the Green Square so I just take this drag it over right about here and right about there and then down here and up there actually I want to pull it up just a little bit more cuz I need to get past those corners there right there and these actually needed to come in a little bit it's good thing I watched that there we go so now that it's in there we should be able to apply go back over to our game and notice that our buttons no longer doing that weird stretching we still always have a constant border size there the next thing I want to show you has to do with this text right here the default unity text looks pretty bad and it always has but there are new options and in fact they're even built into the editor now used to have to go to window and then go to package manager and select text mesh but if you're in a newer version of unity it's already there so I can just select my button and go to game object go to UI and tex-mex it's gonna give me a little pop-up saying that it needs to import some essentials and I'll always hit yes for that because we need those essentials it's really just the font files and the shaders that we need and close that out then I'll make this text mesh text a child delete the other text maybe put some words in here like hello Jason and maximize this button so to do that I select the rect transform tool right here hold down shift and alt well that was all thin shift and then click on this stretch button there we go now our text is stretched out in yard you see it's a lot crisper but we get a ton of other options with text mesh pouch as well it's not just crisp text we have well outlining font selections coloring highlighting pop-ups all kinds of cool really interesting features we can even animate the text so if you're doing anything with text and unity definitely use text mesh Pro the next section of the editor that I wanted to show you actually required me to write a little bit of example code so I've set up a car script and a car game object and then I want to go to window and then general and console it was actually already open down there and it probably is for you as well but if you didn't know that I can't find it that's how you get to it so here we have our console window this lets us see information warnings and errors I had warnings off that turns info off turns errors off usually I leave them all on but sometimes we'll foot between them there's also a collapse button that collapses multiple instances of the same thing a clear button to clear it all out and a clear on play that clears when we play let's hit play watch it clear the already empty list and then see what it can do well we can see oh look at that we've actually got a bunch of errors and if I check my log speed we've got errors now mixed in with actual log entries if I hit collapse you'll see that these cut down so I just have this many log entries and that many errors faster than I can keep track and I can hide the infos hide the errors etc so we'll stop that go over to my code in fact I can just double click on it right here go directly to the code and see what it is if you look back here it said that hey this is a null reference exception just means that this thing was never initialized so we just edit the code and say equals a new Cuba floats come back in and play the console can be a great lifesaver it really save you a lot of time finding errors and issues and if you just need to log out a little bit of extra stuff that can be really helpful as well but there are some drawbacks that you'll see in just a second look at that bug is fixed now let's take a look at some of the drawbacks of all of this logging to do that we go to window analysis and profiler and what you'll see is a whole bunch of charts and stuff that might look a little bit confusing first thing I'm going to do those just switch out of Timeline view into hierarchy mode I think it's a little bit more approachable at first and then take a look at this CPU usage section this is actually showing us how much CPU is being used and what our frame times are now if I click in here it'll stop and pause the execution of our game and I can actually expand out this hierarchy to see what's taking time and how much time it's taking we can see right here the time in milliseconds for our player loop is eleven point seven eight which is still gonna get us well over our 60 frames a second well not well over but over enough and we can expand out here and keep expanding keep expanding and if we look right here you'll see that we're actually spending about a millisecond almost every frame just logging this extra stuff out so logs are great they're really useful don't leave them in in your code unless you absolutely need them pull them out or strip them out or use something else when it comes to actual production release one other really important thing to see in here is the GC Alec this is showing how much garbage is allocated which is what causes those garbage collections that cause a freeze up on a mobile device or virtual reality or something so if you're working on a device that's not basically a Windows or a desktop app you want to look at the garbage collection allocation as well and you'll even see big spikes appear in here eventually when when the allocations actually hit if we check that box right there we're not going to get any now because we're really allocating that much but if I let it run long enough we'd see a big spike in the allocation cleanup and collection the last thing I wanted to show with this script is the debug view of the inspector I know a lot of people don't use this and don't know it exists but it can really save you a lot of time so if we look at our car script I actually have a private average speed float here it's just meant to keep track of the average speed it's not very efficient or anything like that but I wanted to be able to say hey as I turn the speed up look average speed goes up and as I turn it down the average speed slowly goes down but doesn't go instantly because it's the average over the last hundred frames so what if I want to look at that value well I can first drag this over so you can see it click this little drop down hit debug and drag that back over and now you'll see that I can see all of my private variables I can see this average speed I can't adjust it but I can actually look at it now I don't want to stay in this debug mode most of the time because it does break custom inspectors like the transform inspector I don't want to use the transform like that I want to use it in normal mode but it is very important to know that you can bounce back and forth between those in fact you can even go here add a tab and add another inspector and just set one of these inspectors to be debug mode and one to be in normal mode if you wanted to or dock them or whatever like I said most of the time I just kind of switch back and forth though the last thing I want to show you is a little bit of a bonus and something that a lot of people don't use and that's the test runner we go to window general and test runner and it pops out every single time but I can read Ock it and this allows me to run my unit tests that are built in unity now if you're not doing any unit tests in unity I highly recommend you check it out I've got a couple videos on it and I can link some other series on it I think it's a really important thing and can really help your projects and again this window is built right in they're just ready for you to use and take advantage of so those are some of the most important parts of the unity editor and a lot of what you need to know to get started using the engine if you're not using any of them I highly recommend that you at least try them all out check them out dig in and see what they're about and if you have some other recommendations or suggestions for things that you think people should know about please just drop comment down below I'd love to talk about him some more and even discuss them in the comments also thanks to everybody on patreon really appreciate it everybody and don't forget to Like subscribe and of course share this video with your friends alright thanks again bye you
Info
Channel: Jason Weimann
Views: 81,869
Rating: undefined out of 5
Keywords: unity tips, unity tips and tricks, unity vs unreal engine 4, unity for beginners, unity vs ue4, unity3d, beginner, basics, development, c#, unity tricks, unity tutorial, unity, unity best tips, unity or unreal engine, unity beginner's guide, unity vs unreal engine, unity 2018, unity beginners guide, coding, brackeys, game dev, how to make a game, unity tutorial beginner, #unitytips, how to make a game in unity, beginner friendly, unity 2019, unity for beginners 2018, gamedev
Id: XN4tHXvB6D8
Channel Id: undefined
Length: 16min 1sec (961 seconds)
Published: Wed Jan 30 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.