Monster shadow

VIDEO

Organize your Project - Unity Tips and; Tricks

Description:
Learn how to keep your growing project neat and organized. A messy Unity project can increase the development time of your game and fill it with unnecessary searching and repetition.
ADD A COMMENT

Jarosław Polański
Thanks for the great videos! Keep in mind that: 1. If you move your 3rd party assets to different subfolders you may have problems with updates in the feature. Unitypackage importer will basicly duplicate every file from a packge you update, because it will recreate this package in a default folder. Than you have to move it manually to a desired location. 2. A developer menu is cool thing but it's more helpful to create in game "cheat menu". In this way your "developer code" (excluding UnityEditor code) can be also used by testers at runtime.
meowsqueak
Thanks for the vid, I wasn't aware you can hook up a Developer Menu so easily - very handy. Since you asked about tips for organising projects, I have a few to offer based on my own experience: 1. When working with the UI objects (in prefabs of course), it's useful to disable Auto Save, so that you can revert an entire chunk of changes easily. Unity's Undo system when working with UI (especially auto layouts) is flawed, so if you leave Auto Save on, you can put your UI into a bad state that you can't get it out of without rebuilding it from scratch (or restoring from source control). You can literally go around in circles. Having Auto Save disabled means you can just revert the prefab changes and go back to something that was working properly a few minutes ago, and try again. 2. Use source control - something like git is fine. Make regular commits and if you can use a remote repository as an extra layer of safety (not a real backup, do those too). I also use git-lfs to keep my larger assets, and the nice thing about GitLab (rather than GitHub) is they give you a much more generous LFS quota for private projects. Grab a .gitignore and .gitattribute files from: https://github.com/github/gitignore/blob/master/Unity.gitignore and https://hextantstudios.com/unity-gitattributes/ 3. Yes, use prefabs lots, and use nested prefabs too (a natural consequence). However keep careful eye on your Overrides - especially when you are sharing prefabs between multiple Scenes. If you make any changes, be aware of your context, and make sure you apply those changes to the correct layer in your nested hierarchy. Getting this wrong can cause hours of headaches and it can quickly become a major issue if working with other people (see next item). Overrides can get lost in the middle of the nested hierarchy, so be careful. 4. if working with other people (e.g. via git), strive to put everything at the top level of each of your scenes into a prefab, and make sure you and your team-mates are strict about applying overrides correctly (see item 3). Make sure each prefab has no more than one developer is working on it at any one time. This will avoid git conflicts on the Scene file itself (a nightmare) or on prefabs (a bad dream at best). To eliminate scene-level conflicts, try to aim for *zero* scene-level overrides (although unfortunately Unity will fight you on this with auto changes from Editor scripts so you'll often have many overrides you simply can't revert or apply, and Unity's interface is almost useless for mass override management).
meowsqueak
@Tarodev I think it defaults to text now, although some third-party assets are sometimes provided in a binary serialisation format, which can cause issues if you modify them (which is another tip - make copies of third-party assets before you modify them, otherwise you'll have trouble updating them to a newer version in the future, especially if newer versions remove files).
Tarodev
@meowsqueak Can't say I've come up against this problem, but I'll take a look into it to cover as many bases as I can in the video. Thanks mate!
meowsqueak
@Tarodev that reminds me - another is to set the Unity default serialisation format to text (not binary) so that tools like git will work properly. I think newer versions default to text these days but it’s a good idea to check.
Tarodev
Fantastic source control tips. I have a git video planned for the future and you gave me some more solid points. I'll credit you.
İlyas Köse
I discovered your channel today. I watched all your vids and liked. I sucked your knowledge :D . Keep going love to see new videos.
Tarodev
Haha! So glad you're a fan of my content. I'll keep delivering the best I can.
Virtuwolf
It's crazy how much creating the Developer menu is overlooked at first lol. Keep up the good vids, my dude!
srisrid multi purpose channel
Make this a series please :)
Tarodev
I've got a new more planned! :)
Tarodev
I'd love to hear any quick tips you use to organize your project!
SEE ALL COMMENTS


Transcript:

all right so what i'd like to show you today are just a few tips and tricks
that i've picked up over my years of uh game development just to organize
the way that you manage your project and to keep it clean and tidy
so let's get started so let's start with the hierarchy so this is only a small
scene but and there's only a few objects in it
but when the scene gets massive it's uh it gets convoluted and
hard to find what you need to find so what i'll do is i'll create
a new object and i'll call this managers and i'll just zero this out
now with managers i'll have up top and i'll put i'll grab like my game manager
i'd probably have a sound manager or like a board manager or
you know whatever and now they're all there so then i'll create another object
and this one i will have as a divider like that and we'll zero that one out
too and then i'll do the rest for the rest
of the scene so for example the next one would be
i'll have a setup which will be for my cameras and lighting and all that
i'll have a environment all the actual physical game objects that
we've got there and then i'll have if i've got more than one canvas i'll
have a canvases [Music]
object and then i'll just duplicate that a few times
name them the same so let's organize this
directional light events and main camera let's check that all in the setup
grab our objects put that in environment grab our canvas and put it in canvas and
then we'll just separate them with our separator objects
just so that there's a clear distinction between them so now
you know exactly where to go to grab whatever object it is you need
next in our project view uh as i said before this is just a small
project but as you can see i've got some scripts scenes models materials and then
i've got some third-party assets here so the first thing i'll do is as scripts
is the most commonly accessed folder for me
it may not be for you but what i like to do is i like to grab my most used folder
and i'll add an underscore before it and that way it will always be at the top
and i never have to scan to find where i need to go so that's a
good way to you should always do that with your most
commonly accessed folder in your project next i've only got two third-party
assets right now but imagine if you've got 10 or 15 it would
cause a lot of root level pollution there so what i do
is create a new folder and i'll call it
imported assets generally you could call it like third party
assets or just third party or whatever you want to call it
and i'll just drag those in there and that keeps them
out of the of your actual game logic and and materials and stuff i suppose
so the next tip is being able to trigger certain events in your game as a
developer uh without having to get into your game
and do them manually so for example if there's something you need to debug at
the end of a level you traditionally when you're first
starting out you would get in your game and like finish the
level as ridiculous as that sounds and then debug that
that problem or for example if you want to unlock all your skins or clear your
progress or whatever you should have an easy way
as a developer to do that so what i do is i create a developer script
you can call it whatever you'd like and then you don't derive from mono
behavior it's just a normal class and you create some static methods in
this class and you decorate it with the menu item
attribute and as you'll see here i've got
developer slash clear save so developer will be
the root level object and then clear saves will be the name and i'll
show you that now so developer and then i've got my things
here that i can click whenever i want so for example here i i'll just clear
all the all my progress in the editor or my
saved games or what have you and then here i'll just unlock all the
skins but you could do whatever you want for
example you could you could grab your player and then teleport it to a certain
location you could have certain certain like if you've got
multiple zones in your game you could have a bunch of methods here
that will walk you to all those specific zones while you're playing the game
super handy and it will save you a ton of time
the last tip i'd like to give is just to ensure that you're using prefabs
as much as you can and whenever you can so for example i've got these three
cubes here and they've all they all share
a certain attribute which is they've all got a rotator script that i've got here
on it so when i press play they're all
rotating in the same way now what if i had a hundred or a
thousand of these objects in my scene and i wanted to
speed up the way that the the way that they spin
so for example if i just came in and i've got my orange cube selected here
and i wanted to just speed it up only that one is going to be affected so
technically what i should have done here is i should have
created a prefab folder i should have grabbed it and made it a
prefab like that and then
now that i've got this prefab here i can either duplicate it here in the same
or i can just drag them out here not taking time to keep them all
in line and stuff but just to show you and now
now i can simply go to one of them and i can increase the speed and then
ensure that i override the changes there in my prefab menu
and now they're they're all going um well actually i've got them
completely have a look what i've done there
yeah okay they sometimes sometimes this perspective looks correct but uh you're
way off uh anyway so if you want more
information about prefabs i'll put a little annotation up here
um i think i'm pointing the wrong way no up here
up this way um so you go check that out and if you
learn something from these tips let me know and uh subscribe and i'll see you
next time so
you