unity c# static access non static
// To access a non static variable from a static function create a static instance
public class ExampleClass : MonoBehaviour
{
static ExampleClass instance;
string NonStaticVariable = "Hello";
void Awake ()
{
// Assign the instance to this class:
instance = this;
}
static void DoSomething ()
{
// Write the value of NonStaticVariable to the console:
Debug.Log(instance.NonStaticVariable);
}
}