A namespace cannot directly container members such as fields or methods
Do not put members of a type outside of its scope.
Scope is denoted by curly braces { }.
public class Example : MonoBehaviour
{ // <- The start of the class scope.
// Inside the class scope.
} // <- The class scope has ended.
using UnityEngine;
// Incorrect, do not place a member outside of the class scope.
public Transform Target;
public class Example : MonoBehaviour
{
// Correct, the member is inside of the Example class' scope.
public Transform Target;
}
using UnityEngine;
namespace MyNamespace
{
// Incorrect, do not place a member outside of the class scope.
public Transform Target;
public class Example : MonoBehaviour
{
// Correct, the member is inside of the Example class' scope.
public Transform Target;
}
}