Author Topic: Change Sprite image in Runtime  (Read 39034 times)

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: Change Sprite image in Runtime
« Reply #15 on: November 04, 2012, 01:25:14 PM »
I see what you mean, but this is not my problem. I actually see the sprite that is stretched.
The problem does not appears on the Editor but on iOS...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Change Sprite image in Runtime
« Reply #16 on: November 04, 2012, 01:50:34 PM »
I can't tell you what's wrong then. The behaviour should be exactly identical. NGUI doesn't do anything different on iOS.

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: Change Sprite image in Runtime
« Reply #17 on: November 04, 2012, 02:39:31 PM »
Yup I know... but I have what's attached :(



In some other projects, I had to create a coroutine and do :
  1. yield new WaitForEndOfFrame()
  2. mySprite.MakePixelPerfect()

Maybe it has something to do with being in a draggable panel or something like that?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Change Sprite image in Runtime
« Reply #18 on: November 04, 2012, 04:57:46 PM »
Works everywhere but iOS? That just seems strange to me. You might have to investigate that one...

nah0y

  • Sr. Member
  • ****
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 430
  • \o/
    • View Profile
Re: Change Sprite image in Runtime
« Reply #19 on: November 05, 2012, 12:18:16 PM »
Seems like I was doing this in an Awake method, and the object was not activated yet.

So mainTexture was NULL and in MakePixelPerfect, it wasn't changing the scale!

Weird it's working on Editor and WebPlayer but not iOS though...

deckard

  • Guest
Re: Change Sprite image in Runtime
« Reply #20 on: December 04, 2012, 12:10:12 PM »
Work perfectly !!
Thank !!