Change Namespace Folder Name
Followed by 3 people
Answered
Hi there!
I'm using Rider in a Unity project, and it's general practice to store classes in a directory called 'Scripts'. This results in Rider suggesting my namespace be:
Scripts.Gameplay.Environment
(For example.) I found that you can tell a folder to not influence namespace ( https://www.jetbrains.com/help/rider/CheckNamespace.html ), but what I'd love is to instead be able to change what that folder's namespace should be. So I can change my 'Scripts' directory's suggested namespace to the name of my game.
Thanks!
Please sign in to leave a comment.
I am afraid, it is not possible. You may add one more folder with the game name, if you like.
I have found a Unity setting which helps setting default namespace, have you tried it?

https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/6711722-set-the-default-namespace-of-generated-unity-proje
Hey Ivan,
Thanks for the suggestion! That does fix the issue for my game's classes, unfortunately it simply moves the issue to classes that I use between games. I think your suggestion of a folder between Scripts/ and the classes is the best solution, in lieu of being able to change what a folder namespace contribution should be. It adds an 'unnecessary' directory level, but does keep automatic namespaces etc. functioning. A worthy trade off I think.
Thanks very much!
Hey Adam. What I Typically do is to avoid having the "Scripts" folder. It honesty it seems both silly, and naive to have one or several universal scripts folders.
Instead I encourage you to organise the entire project by features, or project areas. It helps avoid a lot of redundant "where is that thing now". : )
Hi Dta,
Thanks for the suggestion. I actually organise my projects like so:
Assets/
0 - Project Name/
Materials/
Prefabs/
Scripts/
ProjectName/ (After Ivan's suggestion)
Gameplay/ (Namespace)
UI/ (Namespace)
...Other namespaces.
NonProjectSpecificClass.cs
...Other folders.
...Asset Store assets.
I've never had an issue finding scripts I need! Though I use folders within my Scripts folder to divvy them up into relevant sections/namespaces, rather than one huge class dump. But everything is grouped logically, and each folder is usually relatively self-contained (where possible, anyway). I assume this is similar to how you lay out your projects.
However I like keeping all of my scripts under the same parent folder. I think it keeps the project more easily understood by anyone else that needs access to it, and provided your folders/namespaces within are descriptive enough there shouldn't be any problems finding what you need!
Thanks again for the suggestion however.