Skip to main content


What are namespaces?

Namespaces are a fundamental feature in C# and are used to control the scope of your projects.

When developing anything with UdonSharp, declaring your own namespaces should be one of the first steps of your development process.

If a creator doesn't declare their own namespace for their UdonSharpBehaviours, all of their classes will be exposed to the entire project by default and may cause misunderstandings and confusion, especially amongst beginners.

How to declare a namespace in UdonSharp?

In order to declare your own namespace for a project, all you have to do is encapsulate your class in curly brackets, lead by the namespace keyword and your desired namespace.

namespace Varneon.ExamplePrefab
	public class ExampleClass : UdonSharpBehaviour

It is highly recommended to always have the first element of the namespace be your own name (or brand, if you have one).

DO NOT use anyone else's name for the namespace unless you are working on the project for them!

How to access classes in other namespace?

In order to access classes in other namespaces, all you have to do is use the using keyword to extend the scope of your project to that other namespace

using Varneon.ExamplePrefab;

namespace Varneon.OtherExamplePrefab
	public class OtherExampleClass : UdonSharpBehaviour
    	private ExampleClass exampleClass;

Usage of namespaces makes it clear who is the developer of the project and makes it often easier to find specific project's scope image-1659620217781.png

TLDR - Why use namespaces?

  • Define clear scope for your project
  • Prevent classes and enums from leaking to the default project scope