Change Namespace Folder Name

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!

0
5 comments

I am afraid, it is not possible. You may add one more folder with the game name, if you like.

0

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!

0
Avatar
Permanently deleted user

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". : ) 

0

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.

0

Please sign in to leave a comment.