Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

C# how do I return the scale values of an object?

Discussion in 'Scripting' started by From-Soy-Sauce, Sep 2, 2014.

  1. From-Soy-Sauce

    From-Soy-Sauce

    Joined:
    Jan 7, 2014
    Posts:
    162
    After I figured out about transform.position.x, I had thought there would be some kind of a transform.scale.x

    But I don't see one.

    Is there a way to return this value? And if so how would I go about doing it?
     
  2. parandham03

    parandham03

    Joined:
    May 2, 2012
    Posts:
    174
    print(transform.localScale.x);
     
  3. From-Soy-Sauce

    From-Soy-Sauce

    Joined:
    Jan 7, 2014
    Posts:
    162
    Thanks it works!
     
  4. brianasu

    brianasu

    Joined:
    Mar 9, 2010
    Posts:
    369
    You have to be careful since it's local scale. Position is world position. You can use lossyscale but it's not accurate if you rotate your parent when you have a scaled child.