Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How To Say That in c# ?

Discussion in 'Scripting' started by m-y, Feb 6, 2015.

  1. m-y

    m-y

    Joined:
    Sep 22, 2013
    Posts:
    470
    i want the transform scale decrease if secounds == 20
    i try that code
    but it is give me error
    i think that i have to use vector 3
    right ?
    Code (CSharp):
    1.     if(secounds++ ==20)
    2.         {
    3.             print("20secounds");
    4.             transform.lossyScale.x --  ;
    5.                 transform.lossyScale.z --  ;
    6.                     transform.lossyScale.y -- ;
    7.  
    8.         }
     
  2. tango209

    tango209

    Joined:
    Feb 23, 2011
    Posts:
    379
    Need more info in order to help:

    What is the error?
    What type is the seconds variable?
    How is seconds being changed?
    I'm not sure print is a valid command, try Debug.Log("20 seconds");
    Try setting a Debug.Log() in the if statement to see if it even enters it.
    lossyScale is read only according to the documentation.
    try this instead:
    transform.localScale = new Vector3(transform.localScale.x - 1, transform.localScale.y - 1, transform.localScale.z - 1);
     
  3. BenZed

    BenZed

    Joined:
    May 29, 2014
    Posts:
    524
    print is just a MonoBehaviour shortcut for Debug.Log
    It's valid.

    Otherwise, listen to @tango209
     
  4. tango209

    tango209

    Joined:
    Feb 23, 2011
    Posts:
    379
    Learn something new (or a hundred lol) everyday, thanks!
     
  5. IchBinJager

    IchBinJager

    Joined:
    Dec 23, 2014
    Posts:
    127