Unity: Null while making new class instance
<p>I got stuck in pretty dumb situation: I'm making new instance of the generic class but it returns "weird" null.</p>

<pre><code>    Rule rule2 = new Rule(); // initiate the class
    Debug.Log(rule2); //1st debug
    rule2.RuleSetup(r: "CaughtEnough", li: 0); //setting up the parameters
    Debug.Log(rule2.rule); //2nd debug
</code></pre>

<p>1st debug gives me</p>

<pre><code>    null
    UnityEngine.Debug:Log(Object)
</code></pre>

<p>at the same time setting up the parameters works, and 2nd debug gives me</p>

<pre><code>   CaughtEnough
   UnityEngine.Debug:Log(Object)
</code></pre>

<p>which is what supposed to be in the proper class instance.</p>

<p>One (only so far) issue that it is bringing to me is that if whitin this Rule class instance I call</p>

<pre><code>   Invoke(rule, 0f);
</code></pre>

<p>it gives me the NullReferenceException error. But at the same time the actual function</p>

<pre><code>   CaughtEnough();
</code></pre>

<p>works just fine and as expected.</p>

<p>Any ideas what could be the source of the problem and how to overcome it?</p>

<p>UPD also posting setup part of Rule class, as asked, though it is straightforward</p>

<pre><code>public class Rule : MonoBehaviour {

public string rule;

public int leftInt;
public Dictionary&lt;string, int&gt; leftDict;
public float countdown;

public int outcome;

public CatchManager catchMan;
public Net net;

// Use this for initialization
void Start () {
    RuleSetup();   
}

public void RuleSetup(string r = "NoRule", int li = 0, Dictionary&lt;string, int&gt; ld = null,  float cd = float.PositiveInfinity) {
    rule = r;
    leftInt = li;
    leftDict = ld;
    countdown = cd;
}
.....
</code></pre>