Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: tinyutopia on September 15, 2012, 03:04:01 PM

Title: adjusting the dimensions of UISlicedSprite in script
Post by: tinyutopia on September 15, 2012, 03:04:01 PM
I feel like this should not be too difficult, but I cannot get any results with the solutions proposed in this forum. Currently I have this, which does not appear to scale the sprite at all.

public GameObject Icon;
Icon.transform.localScale += new Vector3(1.5f, .1f, 0);

Is there another way to change the dimensions of a slicedsprite so I can keep changing it throughout my script?
Title: Re: adjusting the dimensions of UISlicedSprite in script
Post by: dlewis on September 15, 2012, 08:42:20 PM
I've never done a += operator on a transform component. Try assigning the local scale to a temp vector3, add to it and then assign it back

  1. public GameObject icon;
  2. Vector3 scale = icon.transform.localScale + new Vector3(1.5f, 0.1f, 0.0f);
  3. icon.transform.localScale = scale;
Title: Re: adjusting the dimensions of UISlicedSprite in script
Post by: ArenMook on September 16, 2012, 01:23:52 AM
Sprites are in pixels. If your sprite is 200x100 pixels, adding (1.5, 0.1) to it will simply make it (201.5, 100.1), which is going to be barely visible.