Author Topic: Sprites in prefab reverting  (Read 23608 times)

boofcpw

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 30
    • View Profile
Sprites in prefab reverting
« on: May 13, 2014, 11:27:36 PM »
Hey,

Recently I have been experiencing an issue with buttons in a prefab.

Whenever I change the sprite that they use, upon applying the prefab, the sprite reverts back to what was originally in the prefab.
I haven't experienced this before, so I'm not sure if I'm doing something silly or there is an issue with the new version, but any help would be great!

boofcpw

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 30
    • View Profile
Re: Sprites in prefab reverting
« Reply #1 on: May 13, 2014, 11:35:27 PM »
So I have figured that this only happens to buttons with box colliders. If I remove the box collider then apply the prefab, the sprite does not revert. However, when I add a new box collider then apply, the sprite once again reverts. Im pretty stumped.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Sprites in prefab reverting
« Reply #2 on: May 14, 2014, 06:22:58 AM »
In what version of NGUI? This was addressed back in 3.5.8

boofcpw

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 30
    • View Profile
Re: Sprites in prefab reverting
« Reply #3 on: May 14, 2014, 06:01:00 PM »
Version 3.5.9

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Sprites in prefab reverting
« Reply #4 on: May 15, 2014, 12:06:59 AM »
Alright, then I'm not sure what would be the case. The normal sprite is not saved in any way. It's marked as "NonSerialized" in UIButton.cs. Changing the normal sprite actually changes the current sprite's spriteName directly (UIButtonEditor.cs line 52). I don't see anything wrong on my end. Changing the sprite and hitting Apply does not revert in my case, with or without a collider. Is there a step-by-step repro case you can provide?

boofcpw

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 30
    • View Profile
Re: Sprites in prefab reverting
« Reply #5 on: May 15, 2014, 03:21:57 AM »
I created a completely new project and reproduced the issue. Here are the steps required:

new project
import ngui 3.5.9
import two texture
create atlas from two texture (initially created an error. different issue, but probably something to look at)
Add 2d ui to scene
save scene
create panel
create sprite (under panel)
set sprite to use atlas and sprite
add UI button script to sprite
add collider to sprite
save scene
run scene (button works)
Create a prefab
drag panel into prefab
copy sprite (with button on it)
change new buttons sprite
select panel
press apply
second button reverts back to original buttons sprite

Hope that helps

boofcpw

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 30
    • View Profile
Re: Sprites in prefab reverting
« Reply #6 on: May 15, 2014, 03:27:32 AM »
Just another note. Both sprites revert when changed. not just the copied one.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Sprites in prefab reverting
« Reply #7 on: May 15, 2014, 11:57:55 AM »
Reproduced, thanks. I will look into this.

boofcpw

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 30
    • View Profile
Re: Sprites in prefab reverting
« Reply #8 on: May 15, 2014, 05:53:08 PM »
Thanks a lot

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Sprites in prefab reverting
« Reply #9 on: May 16, 2014, 01:03:19 PM »
Fixed in 3.6.0 btw.

boofcpw

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 30
    • View Profile
Re: Sprites in prefab reverting
« Reply #10 on: May 16, 2014, 11:34:09 PM »
Awesome!

boofcpw

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 30
    • View Profile
Re: Sprites in prefab reverting
« Reply #11 on: May 19, 2014, 12:19:32 AM »
Hey, just updated (3.6.0) and am still occasionally getting this issue.

Does the change you did fix buttons which had the issue previously, or does it only fix newly created ones?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Sprites in prefab reverting
« Reply #12 on: May 19, 2014, 12:37:20 PM »
It should fix everything. How often are you still seeing the issue, and is there any way to reproduce it consistently?

boofcpw

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 30
    • View Profile
Re: Sprites in prefab reverting
« Reply #13 on: May 20, 2014, 12:36:29 AM »
Every time I copy a button and change the sprite, it reverts upon pressing apply. This is with an existing project. I have not had a chance today to start a fresh project and get the exact steps required to reproduce the issue, but I cant imagine it would be too different.

Just to clarify, what I am currently doing is:

Copy button (consists of sprite, button, collider, button scale)
Change new buttons sprite
Apply prefab
New button reverts to old buttons sprite.

To be clear, I definitely did upgrade NGUI properly (nuke it from orbit), and am definitely running the latest version.

Ill try get a reproducible from a fresh project when I get the chance. Its a busy week  ;)

boofcpw

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 30
    • View Profile
Re: Sprites in prefab reverting
« Reply #14 on: May 20, 2014, 12:53:29 AM »
I just opened up the project I made to reproduce the issue last time, and upgraded NGUI to make sure that it fixed that issue, but that project is still having the same problem.

I created a new project, and began repeating the steps of the original bug, and found several things

1) not related, but still something that does happen pretty often. When creating an atlas, getting the error "MissingReferenceException: The object of type 'Texture2D' has been destroyed but you are still trying to access it."

2) when I first created a sprite, the sprite name was by default set as a sprite that is in a completely different project (might not be a problem/related, but I found that interesting)

3) the same bug with the applying prefab/reverting sprite.

If you follow the steps I posted previously, you should still be getting the same problem.

Thanks!