Author Topic: UISprite will be reset on apply and save  (Read 3018 times)

HG_CL

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
UISprite will be reset on apply and save
« on: April 15, 2014, 09:02:00 AM »
Hi there,

I'm trying to change the sprites in my Menu. For that I created a new Atlas and deleted the old one. Now when I change a sprite and hit apply prefab the Sprite will be set to a Sprite that was in the old Atlas. That also happens when i save my Scene. Is there anything that I don't consider?

Regards
CL

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISprite will be reset on apply and save
« Reply #1 on: April 15, 2014, 09:54:36 AM »
Nothing off the top of my head. Sounds unusual. Any way for me to reproduce it on my end?

HG_CL

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: UISprite will be reset on apply and save
« Reply #2 on: April 16, 2014, 01:35:59 AM »
Hi,
Not really.. I just created a new atlas and started to replace the sprites. At the beginning it worked fine, but after I replaced about 75% of the sprites it started. When it first appears I decided to do a rollback of our project. Then again I created the new atlas, start to replace and after a while the same problem comes up again. Deleting the old atlas before starting to replace the sprites also doesn't help. In that case the sprite will also be reset in the inspector, but since the atlas doesn't exist anymore no sprite will be shown in scene view.

I really don't know how you could try to reproduce this. Maybe you can give me a hint how to properly replace sprites ;)

HG_CL

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: UISprite will be reset on apply and save
« Reply #3 on: April 16, 2014, 02:51:35 AM »
Hi,
Seems like that it has something to do with prefabs? I broke the prefab instance an I was able to change the sprites. But I can't create a prefab out of the gameobject anymore because that will also make the sprites disappear. For now I will leave it that way, because I don't think that I need this menu as a prefab. So maybe you can try to reproduce it now ;)

Thanks and kind regards

HG_CL

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Re: UISprite will be reset on apply and save
« Reply #4 on: April 16, 2014, 03:30:38 AM »
And its me again, sorry for spamming :(

Not it works for saving, but I have to deactivate/activate some popups in the menu. When I deactivate an object the sprites will also reset. Is it possible that i screwed up the whole structure? Has it something to do that the complete menu is based on one gameobject?

Agent_007

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 5
  • Posts: 27
    • View Profile
Re: UISprite will be reset on apply and save
« Reply #5 on: April 16, 2014, 07:04:25 AM »
We have same issue with 3.5.6

In our case it saves the correct prefab on Apply (so if we reload scene it shows what it should be), but for some reasons in current scene it reverts the UISprite to previous one.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISprite will be reset on apply and save
« Reply #6 on: April 16, 2014, 11:11:36 AM »
I may have an idea for what's causing it. It's Unity being retarded in the head. Open up UISprite.cs, go to line 65 and add [System.NonSerialized] above it like so:
  1.         [System.NonSerialized]
  2.         protected UISpriteData mSprite;

Agent_007

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 5
  • Posts: 27
    • View Profile
Re: UISprite will be reset on apply and save
« Reply #7 on: April 17, 2014, 06:08:28 AM »
I tested out that, but it didn't help. Then I noticed it might have something to do with Sprites part of UIButton. It seems that Normal of Sprites returns to old value when Apple is pressed, but Hover, Pressed and Disabled keep their new sprite.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISprite will be reset on apply and save
« Reply #8 on: April 17, 2014, 11:24:09 AM »
Add the same prefix to UIButton's mNormalSprite and mSprite too:
  1. // Cached value
  2. [System.NonSerialized] string mNormalSprite;
  3. [System.NonSerialized] UISprite mSprite;

Azura

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: UISprite will be reset on apply and save
« Reply #9 on: April 17, 2014, 12:13:59 PM »
I actually just came on to ask about the same issue.

I have a prefab with a basic sprite on that I wanted to replace. I change the sprite from the drop down lister and when I click Apply is reverts back to the previous sprite.

I have had this happen before when I made button prefabs. I made a 1 prefab and made 2 duplicates in the hope to save time, but when I would try to change the sprites out and Apply they would always revert back to the 1st sprite from the initial prefab. The only way around I found to fix it then was to just make 3 individual button prefabs from scratch.

Will try your suggestions and get back to you.

EDIT: Adding the prefix to the UISprite and UIButton script seems to have done the trick! Thank you for the help =]
« Last Edit: April 17, 2014, 12:38:04 PM by Azura »