import class which is outside a namespace, class doesn't have a namespace

Hello, this is a beginner question, I have a class

public class PauseGame : MonoBehaviour
{
...
}

it doesn’t have a namespace.

I have another class :

namespace UnityEngine.InputSystem.Samples.RebindUI
{
    public class RebindActionUI : MonoBehaviour
    {
...
    }
...
}

it does have a namespace.

How do I call “PauseGame” script/class/component in my “RebindActionUI” class ? The solution I found is to move the “RebindActionUI” script in my assets folder instead of keeping it in its original folder “/Samples/…”. But there must be an easy answer to this which I’m missing

hello ? I bumped into my own question months later, with no answers … I feel like there should be a basic answer to this, idk …

Here is a more detailed version :

I have this c# file :
8718663--1178718--upload_2023-1-10_6-58-47.png

it has NO NAMEPSACE, the assembly is the default one : Assembly-CSharp.
This assembly doesn’t have a Assembly definition file I think (or does it ???) but that’s besides the point for now.

I am trying to ACCESS the new input system SAMPLES c# scripts, for REBINDING. (Especially the one called RebindActionUI.cs) Which are contained in the following NAMESPACE :

THE ASSEMBLY IS THIS ONE :
8718663--1178730--upload_2023-1-10_7-1-16.png

THE ASSEMBLY DEFINITION FILE LOOKS LIKE THIS :

I HAVE linked the Assembly-CSharp and the Unity.InputSystem.RebindingUI assembly. (right click the Assembly-CSharp in the solution explorer (whatever it’s called on the left side of VS 2022) → dependency build → check the Unity.InputSystem + Unity.InputSystem.RebindingUI boxes)

Now, As you can tell in the first picture. The namespace Samples apparently does NOT exist.
What am I doing wrong ??? Why can I not access a simple script from a namespace/folder/assembly ?? Thanks in advance for any response.

Visual Studio doesn’t control the script compilation. Changing things in the solution explorer does absolutely nothing.

Enable “Auto Referenced” on Unity.InputSystem.RebindingUI. Default assemblies like Assembly-CSharp will not pick up asmdef assemblies unless Auto Referenced is enabled.

4 Likes

Thank you ! I just found it too by testing every thing I could, right before going insane. I am glad to learn about this too : “Changing things in the solution explorer does absolutely nothing.” makes sense now.

This is the box to check (enable) for anyone searching :

8718846--1178769--upload_2023-1-10_9-32-20.png

1 Like

That did it for me as well. Just had to restart the editor. I am using VSCode.