Search Unity

operator "??" in Unity 4.3

Discussion in 'Editor & General Support' started by Itmindco, Nov 13, 2013.

  1. Itmindco

    Itmindco

    Joined:
    Nov 13, 2013
    Posts:
    3
    Why the operator C# "??" has stopped working after update to Unity 4.3

    this code:
    Code (csharp):
    1. var boxColider = gameObject.GetComponent<BoxCollider> () ?? gameObject.AddComponent<BoxCollider> ();
    not work.

    this code:
    Code (csharp):
    1.  
    2. if (gameObject.GetComponent<BoxCollider> () == null) {
    3.     var boxColider = gameObject.AddComponent<BoxCollider> ();
    4. }
    5.  
    work.