Author Topic: UISprite - size changes on spriteName swap...  (Read 4717 times)

Gregzo

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 64
    • View Profile
UISprite - size changes on spriteName swap...
« on: July 25, 2012, 02:59:56 AM »
Hi!

Must be something silly I'm not seeing. I'm changing the sprite of a UISprite at runtime, swapping between two versions of the same sprite (same size and import settings, same atlas). But one appears about 10% smaller than the other... Transform doesn't change, just the appearance.

Any clues?

Many thanks,

Gregzo

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISprite - size changes on spriteName swap...
« Reply #1 on: July 25, 2012, 07:30:30 AM »
Perspective mode 3D UI? My guess is one is closer to the camera than the other.

Gregzo

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 64
    • View Profile
Re: UISprite - size changes on spriteName swap...
« Reply #2 on: July 27, 2012, 02:20:41 AM »
Hi Aren,

Thanks for the reply.

UICamera is set to Ortho, not perspective.

Transform of the object to which the UISprite is attached doesn't change at all.

Properties of the UISprite dont change neither.

But appearance changes when I assign a new sprite of exactly the same size(UISprite.spriteName).

The object I'm assigning the sprite to is child of an empty object which is the target transform of a UIDrag script. Scale of that object is 1.1.1.

Thanks for any insights!

G


ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISprite - size changes on spriteName swap...
« Reply #3 on: July 27, 2012, 06:11:22 AM »
There is no reason why it would change its size if the sprites are of identical size. Are you certain they're identical? They may have been identical before getting added to the atlas, but had some alpha trimmed differently, resulting in different actual sizes.

Gregzo

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 64
    • View Profile
Re: UISprite - size changes on spriteName swap...
« Reply #4 on: July 27, 2012, 11:33:23 AM »
I had a feeling it would be something silly...

Had completely forgotten about trim alpha.

Many thanks!

G