Search Unity

how to make a variable null

Discussion in 'Scripting' started by Gamer_, Jan 5, 2011.

  1. Gamer_

    Gamer_

    Joined:
    Dec 4, 2009
    Posts:
    74
    HI to all,
    i want to make a variable null.I dont know how to achieve in javascript.

    var gameobject1 : GameObject;


    if(gameobject1 == Null)
    {
    gameobject1 = GameObject.Find("Player");
    }
    else
    {
    gameobject1 = Null; ///// #pragma strict doesn't allow this gameobject1 = "" ;
    }

    help me guys ,Thanks in advance


    regard's
    rajesh
     
  2. Chris-Sinclair

    Chris-Sinclair

    Joined:
    Jun 14, 2010
    Posts:
    1,326
    Null should be lower case: null


    Perhaps also you need to give gameobject1 an initalized value before accessing it:

    var gameobject1 : GameObject = null;

    if (gameobject1 == null)
    {
    .............
     
  3. BlackMantis

    BlackMantis

    Joined:
    Feb 7, 2010
    Posts:
    1,475
    What kind of errors you got?

    Null should be lower case: null - lol how did i miss that?
     
  4. Gamer_

    Gamer_

    Joined:
    Dec 4, 2009
    Posts:
    74
    null working fine thanks guys. I thought reserved word change its color to red.