Author Topic: Need help in swapping sprites using a variable that is attached to a panel  (Read 2221 times)

mremus

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
My title may not adequately describe what I am trying to do. In my NGUI UI I have a panel (ID_Panel), with a script attached. In the script I have a variable setup (var This_Panel_Object : GameObject;).  Over in the Inspector I dragged one of the sprites (Sprite_Sailboat) belonging to ID_Panel  into the Game Object slot so that when the game is running and the ID_Panel is active the sailboat sprite is displayed.

What I want to have happen is when the user clicks on another object (let's say a seagull) in the game, the sailboat sprite fades off and a seagull sprite (Sprite_Seagull) fades in.  I have the fade in and out part down I believe, but I am not sure how to code things so that the Sprite_Sailboat sprite in the This_Panel_Object variable gets replaced with the Sprite_Seagull sprite allowing the seagull sprite to be be displayed.  Hope this makes sense.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
I am not sure what fading sprites has to do with replacing panel object variables... Fading in is done via tweens. Replacing variables? That's your code.

mremus

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 23
    • View Profile
Thanks Aren for the reply.  I sorted it out and I apologize for any confusion. Had to just sit back and work through it after a night's worth of sleep.