Search Unity

if statement

Discussion in 'Scripting' started by RankXenon, Jan 27, 2013.

Thread Status:
Not open for further replies.
  1. RankXenon

    RankXenon

    Joined:
    Jan 20, 2013
    Posts:
    48
    is it possible to make a if statement in a f statement?

    something like this:

    Code (csharp):
    1. function Update () {
    2.     if(Input.GetKeyDown("space")){
    3.         if(gameObject.GetComponent("emptyScript").enabled = true){
    4.             print("emptyScript is enabled");
    5.         }
    6.         else(gameObject.GetComponent("emptyScript").enabled = false){
    7.             print("emptyScript is disabled")
    8.         }
    9.     }
    10. }
     
  2. shaderop

    shaderop

    Joined:
    Nov 24, 2010
    Posts:
    942
  3. RankXenon

    RankXenon

    Joined:
    Jan 20, 2013
    Posts:
    48
    Why does nobody answer?
     
  4. Alex Cruba

    Alex Cruba

    Joined:
    Aug 16, 2011
    Posts:
    564
    You will not get more answers with more posts. I'll answer in the other post.
     
  5. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Do not post duplicate topics; it's against the rules.

    --Eric
     
Thread Status:
Not open for further replies.