How can I access a method from a namespace to a class not belonging to any namespace ? (or it does but I don’t know what to use)
EXAMPLE:
//CLASS 1
using UnityEngine;
using System.Collections;
public class Human: MonoBehaviour
{
static public void Hello ()
{}
}
And
//CLASS 2
using UnityEngine;
using System.Collections.Generic;
using System.Linq;
namespace Company.UI.Magic
{
public class SomeClass: MonoBehaviour
{
void Start ()
{
//QUESTION . How can I run Hello Method from here??? Human.Hello() is not working!
}
}
}
NOTE: CLASS 2 WAS IN PLUGIN FOLDER - THIS CAUSED MY PROBLEMS
It’s solved now!
Since your Human is in the global namespace you can access it from any subnamespace without any further actions. However if you have another “Human” class inside your subnamespace or another imported namespace you have to use the “global::” prefix if you want to reference a class from the global namespace.
If you don’t have another class called Human, i’m pretty sure your issue isn’t related to namespaces at all. The namespace “Company.UI.Magic” sounds like some sort of framework of your company. If those classes are in the first compilation group, they get compiled to a seperate assembly than things which belong to the normal compilation group. Things in “Standard Assets” or “Plugins” are compiled together into the “first” assembly. From the normal compilation group (things which are not in Standard Assets or Plugins) can access everything from the first group as the normal group is compiled last so it can reference the first assembly.
Things in “Standard Assets” / “Plugins” can’t access anything from outside those folders. Frameworks should be standalong modules which aren’t dependent on other classes which don’t represent a framework. If you’re unsure what actually belongs to a framework, don’t place those files in Standard Assets or Plugins but move them to a normal folder inside your Assets folder.