The two classes need to stay as they are as changing them will break a lot of functionality so i cant create an instance and cant attach to a gameobject to drag and drop
Any ideas how i can get around this little issue?
public class myClass1 : monoBehaviour
{
public String text = "hello";
}
public class myClass2
{
private myClass1 monoClass = new myClass1();
private void Start()
{
Debug.Log(monoClass.text);
}
}
//THIS DOES NOT WORK
You can absolutly use a reference to a mono behaviour from anywhere (well, you can’t operate on it from a different thread etc so there are constraints). But you must let Unity hook it up. So you can not instance it yourself like you have done.
You can add it to a empty gameobject from your code though.