Very simple question: In c# (in Unity), I create a new custom class from a Monobehaviour class attached to a gameobject:
CustomClass test1 = new CustomClass(t1, t2, 0.5f);
I want this class instance to know who its creator is - it's a coroutine and it should check if it's parent is destroyed. Of course I can pass it like this:
CustomClass test1 = new CustomClass(this, t1, t2, 0.5f);
///
CustomClass(MonoBehaviour creator, string t, string t2, float a);
But, is there a more elegant (=automatic) way to do this? I am aware of the following method for the static functions:
public static void Test(this MonoBehaviour behaviour, float a);
///
this.Test(0.5f);
Is there something like that for a class constructor?