Author Topic: Changed sprite always reset...  (Read 1808 times)

80dots

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 1
    • View Profile
Changed sprite always reset...
« on: March 05, 2015, 07:51:02 AM »
Hello.


I'm making Inventory system using NGUI 3 and Unity 5.

When player select the item on the field, Item slot image will change to Item image.

I'm using ..GetComponent<UISprite>().spriteName = "ItemImage".

It's works well.

But problem is changed sprite image is reset.. when Close and re open Inventory UI.

I used .SetActive(true) and SetActive(false) for showing and hiding InventoryUI.


Is there someone how I can solve this problem?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Changed sprite always reset...
« Reply #1 on: March 05, 2015, 10:13:56 PM »
You can't just change the sprite. You have to alter the code where the sprite is set to begin with. Where is it set from initially? That's where it should be altered, not on the sprite.