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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Resize sprite size via input value

Discussion in '2D' started by Uwei, Apr 1, 2015.

  1. Uwei

    Uwei

    Joined:
    Mar 27, 2015
    Posts:
    6
    I have a sprite 1280*720 and I set the Pixels Per Unit to 1.

    It show 1280*720 in the Scene.

    I want to resize the sprite via input the value in Inspector.

    For example, I input the Width:600 Height:400 in Inspector then it will show 600*400 in Scene.

    I try to add code "GetComponent<SpriteRenderer> ().bounds.size.Set (600f, 400f, 0.2f);" in the Script.

    it's no use.

    How can I implement it?
     
  2. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    why not change the transform's scale?
     
  3. Uwei

    Uwei

    Joined:
    Mar 27, 2015
    Posts:
    6
    I don't think change scale is a good way.
     
  4. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    why not? it doesn't impact draw calls.