Hi everyone, I have a script which instantiates a prefab. as it is called often, and on many scripts, I would prefer to have it as a static function rather than create a reference on almost every script. the problem is, I can’t declare a prefab and then have it called in the static function. I get the error "An object reference is required to access non-static member ‘example’
Here is a snippet that replicates the problem;
public class ExampleForUnityAnswers : MonoBehaviour {
public GameObject Prefab;
public static IEnumerator Example(){
GameObject GO = new GameObject("Prefab");
GO = Instantiate(Prefab, new Vector3(0,0,0), Quaternion.identity) as GameObject;
yield return null;
}
}