10 Unity Tips You (Probably) Didn't Know About

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys I want to give you my 10 favorite Unity quick tips these are all tricks that I personally use and love and I hope that these will help save you headaches and speed up your workflow ready let's go we all know about the start method because if you use Unity you've probably typed it at least a billion times and I actually didn't know this until recently but you can actually change it from a void to an ie numerator turning your start function into a co-routine that automatically starts at runtime this can be handy if you want to start a timer or really just run any kind of Co routine as soon as your game starts running I don't use this too often but it is really nice to know that the functionality is there if you want it when you're testing things to make sure that they're working it can sometimes be really nice to see the values of your private variables in the inspector a good example would be making sure that your enemies are taking damage properly and yeah you could do a debug.log or a print or change the variable to public but those are all kind of a time waster the better and faster way to do it is to just change your inspector to debug mode click on these thoughts up here and select debug this is going to add a whole lot of stuff to the inspector that you're probably not used to seeing but you can see we have our public variables here in white and our private variables Down Below in Gray and if you want to quickly see the actual variable name instead of this prettied up version you can either highlight over top of the variable with your mouse or you can hold the ALT key to toggle the real variable names on and off foreign several objects to an array if you were doing that by locking the inspector and then dragging everything over there's a better way what you can do instead is right click the component header and click properties this will create a duplicate of that component in a pop-out window which will not go away when you're clicking around in your project window so you can go ahead and assign things to your arrays this way instead it's a nice little Time Saver I use all the time also it's not just for scripts you can do it to literally any component in the inspector I really like public properties I prefer them over public Fields because it's nice to have so much control over what can read and what can write to those variables but by default even though this is a public variable it will not show up in the inspector and for the longest time I thought if I wanted to have public variables show up in the inspector that I had to use public Fields but you can actually serialize the property by adding this attribute before the property there you go this is an especially nice way to be able to serialize variables that come from an interface which usually have this get and set properties attached to them I almost always use an eye damageable interface to anything that I want to make damageable and I always serialize the max Health amount by default when you serialize a color in unity there's no option to use HDR or high dynamic range in order to use glow or anything like that it's easy enough to access when you're making shaders in Shader graph but in the inspector from a c-sharp script by default the options not there but all you need to do is add this little color usage attribute and fill in a true twice the first is for the alpha which I guess you can hide if you want and the second is to enable the HDR option to the color maybe this one's not news to anyone I'm not sure but I'm a self-taught programmer and so I never knew what it meant when I saw these triple slashes above functions in scripts well this is how you can actually create that description that shows up when you go to call one of your functions somewhere in visual studio if you just type three slashes it'll automatically fill in all of this so in between these two summary lines here is where you can fill in a really broad description of what the function does that description is going to stay there the whole time that you're writing the function and if you want to write a per variable description you can add it right before this slash parametext here and you'll see that as you cycle through the code the description will change for each variable and if you're writing really long descriptions you might want to break up the lines and you can do that by typing this at the beginning and this at the end of the text that'll make it count as one line so now you can see we've written two lines by doing that now if you have this much stuff above every single function your code's going to look pretty unreadable you can hide this summary stuff in a region which makes it a little bit nicer though I would be curious to know if anyone out there knows of a way to truly hide all of this stuff but still have the comment code show up that would be pretty cool so over the years I've made hundreds of particle systems in unity and the first thing I always started out with is creating a new material for the particle assigning my Sprite to that material and then plugging that material into the renderer to get my basic shape going in some cases you can actually save yourself that entire step by going to texture sheet animation and changing the mode to Sprites and assigning your Sprite in there there's no need to create a new material if you're just using one Sprite for the particle system that is probably the tip that has saved me the most time overall if you've ever followed a tutorial and seen them do this it's actually really easy I personally like doing this just because it looks cool but it saves me a little bit of time here and there as well so if you click anywhere on this line and then hold shift and ALT and then click at the start of this line you'll be able to type in both at the same time now using these two keys will actually line up what you're selecting so if I do it in the middle of the variable name on the second line it'll line up both cursor points there now if you truly want to be able to type in multiple places no matter where on the line you're typing then you'll want to hold alt and control instead and in order to undo the multiple selections just click somewhere else or press Escape if you're wanting to call a function from a reference only if that reference is not null you can actually avoid typing all of this and just put a question mark before calling the function that is the exact same as checking if it's not null I spent years creating empty game objects in the scene and then resetting the transform if you go to edit preferences scene View and check create objects at origin you will never need to do that again that's all I got like the video if you liked and let me know down below which one is your favorite or better yet if you have a tip that should have been on this list but wasn't let me know down below bye I want to give a very special thank you to all of our Hall of Fame patrons Jacob yondak Sandra Kessler Darren Preen throbbing wind Fontaine weight couch and Christopher Nichols as well as our Early Access patrons xioma Ken wait Mason Crow Mr D audio games Jan and Donnie Briggs if you choose to support us on patreon you can get early access to all of our YouTube videos monthly Alpha builds and more
Info
Channel: Sasquatch B Studios
Views: 36,411
Rating: undefined out of 5
Keywords: unity, unity2d, unity tutorial, sasquatch b, unity beginner tutorial, game development, unity tips, unity tricks, unity tips and tricks, unity tips and tricks 2023, unity tips for beginners, unity pro tips, unity hacks, unity best practices, game dev tips, unity save time, unity easy tricks, unity best tips, pro tips, unity beginner advice, unity things to know, unity things you didn't know you could do, unity hidden features, unity unknown features
Id: fmbYlYU7z9Y
Channel Id: undefined
Length: 6min 46sec (406 seconds)
Published: Thu Jun 15 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.