Organizing a project with C#

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By thisischico

I don’t quite understand how to organize a project using C#. With gdscript it’s simple enough: load the type you want into a variable and use it in the script file. C# provides handy namespaces that make it less verbose, but they don’t allow you to name the types like namespaces, so I can’t exactly follow the recommended organization of the project. The way Unity does it terrifies me and I find it completely wrong. So what should I do? Doing away with namespaces would mean losing context, which would require me to manually put it in every type name… :frowning:

Whats your exact Problem? You can use any Namespace you want and attach the scripts to any Node.

juppi | 2022-08-05 13:46

I don’t know how best to organize the project.

If I used gdscript:
Player/.
Player/Player.tscn
Player/Player.gd
Player/Texture.png

However, in C# this would not work, “Player” would be both a namespace and a class.

thisischico | 2022-08-05 14:21

My folder structure looks like this:

src/
scenes/
assets/

Inside the src folder i have subfolders for every namespace.
Lets say your Game is called “MyShooter”, is use MyShooter as root namespace and then MyShooter.Scenes for nodes or MyShooter.Utils for helper classes.

And btw. tscn files go to scenes and textures, sounds, etc. go to assets.

juppi | 2022-08-06 15:40

Unfortunately, this is the “unity way” I mentioned in the beginning, and I find it very inconvenient to scatter closely related things into completely different hierarchies

thisischico | 2022-08-06 21:20

You can took a look a github and check out, how others do it.

Here’s an example of Thrive, a game which you can also find on steam:
GitHub - Revolutionary-Games/Thrive: The main repository for the development of the evolution game Thrive.

Thrive on Steam

juppi | 2022-08-07 07:06