-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a style guide for project organization #3104
Comments
Definitely go for PascalCase, in my experience 🙂 As for animation names, I use snake_case personally (just like file names). |
Godot by default creates nodes in PascalCase, but when creating collisions, it creates a
Godot creates |
Over the years I've arrived at some patterns that are more common (or recommended) than others that I use myself:
I feel that the naming scheme has become rather clear to me (even though the official demos are very bad at consistency). What I miss the most is a the-one-true-hierarchy guideline. Making a mess for yourself is a serious bother and if you decide to rearrange things down the line it will cause headaches in the revision history like when you want to check out a certain file from a certain revision but it changed paths at some point. |
I try to avoid this. In most projects I keep all necessary files for an object in a dedicated folder (for example a |
I agree with you about this, but in this case folders and resources in snake_case has no sense as for me. I would suggest using CamelCase for them too.
I agree. I once tried to sort by type and it was a headache :) |
Creating a folder structure style guide is trickier than the GDScript one, to me. There's no one-size-fits-them-all approach, or general structure that would be inherently better than others. We've actually already had an issue and detailed conversation about that and couldn't reach a consensus. For naming it's quite simple to me as Godot provides us with some defaults. Nodes, which are types, use PascalCase, so tscn and gdscript files should use PascalCase. When it comes to the folder structure, the issue is that the larger the project, the more you end up reusing assets, and the more it makes sense to split data files (sprites, meshes, audio, text...) from your classes. It really depends on the game. And if possible, keeping related files and scripts together is nice as it makes your dependencies and code structure clearer. I'm personally not leaning towards anything in particular. At GDQuest, we use When it comes to the official demos, the only thing I wouldn't do is keep all the files in the |
Ah, I would also treat node structure inside a scene as a separate topic. With signals, nesting scenes, instancing scenes at runtime, patterns... there's quite a lot to say on the topic. It's a little more complex to have a strict style guide there again, and we already have some guides on the matter in the Best Practices section of the official docs. See http://docs.godotengine.org/en/latest/getting_started/workflow/index.html, there's a lot of content there |
Resources should not be
|
@nathanwfranke, But why use |
@Shatur Because the default project files, as well as Godot's source code, use |
@Shatur Godot's source code itself uses PascalCase for class names, yet all file names use snake_case. |
But does it make sense to use |
@Shatur There are arguments for either case, which is why this issue is open - the argument in favor of PascalCase for scenes is because Godot's default name when saving a scene with |
@aaronfranke, sounds reasonable. What if use |
My vote is for PascalCase for two reasons.
|
Regarding your question of the "Assets" folder. It should be discouraged. Reasoning is the same as in ue4.
|
UE4 styleguide from Allar does it by having a top level folder. The third party resource path doesn't change. It keeps its own top level folder. The benefit is now you can compose different projects from the asset library and remove things, but the asset path doesn't need to change. https://github.com/Allar/ue4-style-guide#22-use-a-top-level-folder-for-project-specific-assets- The Allar guide has like 6 subsections on this topic. |
@fire, agree, I using something similar according to the UE4 guide. Except prefixes, because it not needed for Godot. |
Currently there is no style guide for how to structure Godot projects outside of the contents of the scripts. This should include what is encouraged, what is allowed, and what is discouraged (and most importantly, how should the demo projects be organized).
When created, this should probably be placed in project workflow.
Some topics that could be included:
Nodes:
Casing of nodes. PascalCase? Something else? The current demo projects
are fairly mixedEDIT: have all been refactored to PascalCase node names due to a general consensus below and also because that is how Godot cases newly created nodes by default.How often should nodes be grouped together? If there are 30 boxes in a scene, would it make sense to make all of them a child of "Boxes", or maybe group them like "Boxes/Group1" and include several boxes that are next to each other under the same parent?
Should
Node
children be added with their own scripts to add behavior, like "components", or is this way of abstracting functionality discouraged?Files/folders:
Casing of folders. Most of the demo projects use
snake_case
for this.Casing of files. This one's a bit more tricky than the above:
What about for C# projects, where it is generally expected that the file name should match the class name? Should MyClass be in
MyClass.cs
ormy_class.cs
? If the former, should C# projects also use PascalCase for folders and other files to be consistent?If the above, should GDScript files also be this way to be consistent with C# files?
File hierarchy and organization.
When should folders be used at all? Some demo projects have a completely flat directory structure, others (mostly the larger projects) have many subfolders.
How many related files should be allowed to sit next to each other without being in their own folder? If you only have
player.tscn
andplayer.gd
, does that deserve aplayer
folder?If a project has assets from third-party sources, how should they be indicated to be so?
The project I am working on with my brother contains an "Assets" folder for all the stuff we make, and we still have around 30 items in the project's root folder including things like the icon, config files, helper scripts, git stuff, readme/license, C# stuff, translation files, and native libraries, most of which can't be moved to subfolders. Should an "assets" folder containing "as much user-created stuff as possible" be encouraged for large projects?
The text was updated successfully, but these errors were encountered: