I'm developing a project in Unity. I think code sample will explain itself.
NOTES:
-
Module constructor shall not need any other parameter, such as "this" referring to a Container instance
-
Module constructor only parametre must stay as IEnumerator, not Func<> etc
-
Coroutine passed as the parameter, will not be invoked directly (for ex. StartCoroutine(...) )
-
Code logic that's inside the Module CTOR shall not be moved into a seperate method (neither public nor extension method).
class Module { // CTOR public Module(IEnumerator _someCoroutine) { // This is where I need to get the reference to the // instance of a Container class (not "typeof(Container)") // which _someCoroutine method's reference is held, // directly from _someCoroutine parameter } } class Container : MonoBehaviour { Module module = new Module(SomeCoroutine()); IEnumerator SomeCoroutine() {...} }
Aucun commentaire:
Enregistrer un commentaire