Organizing your Code for GameDev - My Solution - Namespaces | Folders

  Рет қаралды 5,223

Jason Weimann

Jason Weimann

Күн бұрын

Multiplayer Mastery Course - game.courses/mp/
Game Dev Course for Beginners - game.courses/bc/
Join the Group - unity3d.group/
Members Get Early Access to Videos - / @unity3dcollege

Пікірлер: 19
@beardedlinuxgeek
@beardedlinuxgeek 8 ай бұрын
Jason, you have been pumping out the content lately. Loving this enthusiasm.
@RobLang
@RobLang 8 ай бұрын
Two things jump out - firstly, you should prefix your namespaces with something unique to avoid collisions. i.e. namespace WeimannGames.Characters.Items. If you were to import a package that also used the Characters namespace then you'll spend ages renaming things. Secondly, you can go even further with this theory and move all assets relating to characters under character. In other industries, code and assets are gradually moving toward domain driven design where the boundaries of your code (you call them features) are drawn along the domain you're working in. In game dev, that's dependent on the game but would include things like player, NPC, enemy, world tile, etc. Then when you organise all your assets, you do it down these domain boundaries. The mesh, materials, textures live next to the C#. When you're changing a feature then everything is in one place. Shared items are clearly shown because they exist outside of any domain folder. You can make huge monolith systems like this (which games are) while keeping complexity down because complexity in OO systems is nearly always through dependencies. Keep up the great work!
@KeyboardKrieger
@KeyboardKrieger 8 ай бұрын
Second that
@midniteoilsoftware
@midniteoilsoftware 8 ай бұрын
I took that approach in my Highland Panic project.
@fokeyjo
@fokeyjo 8 ай бұрын
Yeah.. and Jason Storey has a video where he shows there's some default namespace field, and then shows how you can get it to autofill into the C# template. Just to understand what you're saying about breaking it up into domains, is that like every component (or small group of) is their own mini-package? I've been wondering whether that's a feasible approach, because it's technically how you use 3rd party assets.
@captainufo4587
@captainufo4587 8 ай бұрын
In my experience, you need to smash your face against an obstacle to learn why certain practices are good. I don't mean this in a punishing way, I mean you just won't store in permanent memory a concept unless you experience the need for it. Structure, namespaces and folder organization is one of those. I designed my first game by the seat of my pants and it was a fun and learning experience I'd actually recommend, if one has the resolution to see it through. Once I found myself with 50 scripts under the same namespace all in the same folder, I saw the use for design documents, namespaces, and folder trees, and assemblies. And surprisingly, since I was invested in the project, refactoring the whole thing to be more sane and mantainable was fun and satisfying rather than daunting.
@stas_khavruk
@stas_khavruk 8 ай бұрын
I'm experiencing difficulties with organizing plugins from the Asset Store. Typically, I create a "project" folder (Unity Sources => Project), allowing the plugins' files to install automatically in the top-tier folder. However, I need to create an assembly definition file specifying the assembly contents, including the plugins, to enable IDE autocomplete/IntelliSense and to ensure the project is buildable. How did you address this issue for the "plugins" folder? Did you manually move all downloaded assets and define them in a configuration file, or is there a simpler method?
@alexandernava9275
@alexandernava9275 8 ай бұрын
You should look into assembly definitions. They help with compile time, and can help auto do namespaces.
@nixonscherbarth1974
@nixonscherbarth1974 8 ай бұрын
Hey Jason, Is there any way to still do your multiplayer mastery course? I think this would be a perfect chance to create an Udemy course for example! I think you’re the best Unity „teacher“ out there, but as a student I couldn’t afford 1000 bucks for that course :/
@puretrack06
@puretrack06 8 ай бұрын
Go in depth and add assembly definitions
@SMxYuu
@SMxYuu 8 ай бұрын
Hi Jason, can you talk about how should i structure the Assembly definitions, since it can't cross referencing like Namespace. E.g. what if my Character and Level need to reference each other. What would you do for the Assembly definitions.
@jefflynch
@jefflynch 8 ай бұрын
You can actually cross reference assemblies in an assembly definition. There's a section in the assembly definition for assembly definition references. The CSharp assembly is included by default, but you can add references to other assemblies. The one caveat is that you can't have cyclical references, so you can have both Character reference Level and Level reference Character. It needs to be a one-way dependency. There are also assembly definition reference assets, which is just an asset you place in a folder that allows all of the scripts in that folder to be refenced by an assembly as if they were part of an assembly, but without the formal requirements of an assembly (i e. scripts in that folder can still reference other scripts in assemblies like any other script you write in your project).
@jamesclark2663
@jamesclark2663 8 ай бұрын
My suggestion would be the reconsider your design. Cyclical references like that should be avoided. Consider if it *really* is neccessary that your characters and level need to know about it each other at all and if so, why shouldn't it be a one-way reference. One of the really great things about asmdefs is that they immediately expose these sorts of problems and force you to fix them. Don't fight it. Embrace it.
@josephstar7896
@josephstar7896 8 ай бұрын
Hey jason i have a questiom! If something, some system is goıing to change completely, which approach do you take? Replace all the files of the old system or create new files? I find it hard to manage if old files keep piling up but don't want to delete them all either
@ExpensivePizza
@ExpensivePizza 8 ай бұрын
One of the most annoying things about Unity is how it puts everything in the root Assets folder when you import stuff from the asset store. I know some people like to move things into a Plugins folder but recently I've been trying a different approach... Basically I put all my code and assets in a folder called _Game. That way I don't need to bother moving stuff around after importing it from the store and all my stuff appears at the top of the folder structure.
@manzell
@manzell 8 ай бұрын
I'm enjoying these short videos. I use namespaces but I don't totally understand the purpose of "sub namespaces" - the MSFT C# documentation advises against using the same class names in different namespaces, so you're not really resolving potential conflicts with subspaces.
@Ts1nd
@Ts1nd 8 ай бұрын
Can you make a video showing how did you set up your VS Code? Any tips and tricks etc.
@rsletta
@rsletta 8 ай бұрын
It's Jetbrains Rider, not VS Code.
@newogame1
@newogame1 8 ай бұрын
I just dump everything into one folder
Simple fix for MOST games / code - parameters? - #unity3d #csharp
10:22
АЗАРТНИК 4 |СЕЗОН 2 Серия
31:45
Inter Production
Рет қаралды 896 М.
Top Game Development Tools for Solo Devs | Must-Haves for Unity
10:02
3 Game Programming Patterns WE ACTUALLY NEED.
14:13
Jason Weimann
Рет қаралды 14 М.
Turn your Unity Game Multiplayer, NOW!
3:03
StrawberryDeveloper
Рет қаралды 1 М.
Namespaces in Unity
7:05
Infallible Code
Рет қаралды 61 М.
Scriptable Abstract Abilities
10:53
Jason Weimann
Рет қаралды 9 М.
Animations with Layers in Unity3D - Unity Devs WATCH THIS
18:37
Jason Weimann
Рет қаралды 39 М.
Software Architecture in Unity
7:13
Jason Storey
Рет қаралды 117 М.
How to ACTUALLY get into Gamedev
14:01
DaFluffyPotato
Рет қаралды 722 М.
Organizing code & handling communication between game *systems*
24:45
The Most Important Gamedev Questions In 2024!
11:04
ButWhyLevin
Рет қаралды 6 М.