Author Topic: Rare PITA (maybe bug) with ALL NGUI prefabs losing data  (Read 225 times)

Zyxil

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 37
    • View Profile
Rare PITA (maybe bug) with ALL NGUI prefabs losing data
« on: June 17, 2017, 11:25:22 PM »
I just came across an event that has happened to me maybe four times in the last two years.  It's very rare, but is a colossal pain in the butt when it happens.  I'll share my experience and maybe it will help down the road.

Event: may be more causes, but from what I've deduced: if you close Unity when there is a compilation error in your code, on reopening Unity, all NGUI prefabs will have lost their data (all of it!).

The first time this happened to me, I set about manually resetting all the data that was lost.  It took me several days to recover.

Current fix: I just discovered that you can manually walk your tree, go each prefab, click Revert and then immediately Undo (ctrl+z).  This will restore your data to the values that were present before.  UILabels that had NGUI fonts assigned will still say they are Unity fonts, but if you click to another GameObject and then back again, the data will show properly.

Moral: do not close Unity with code that won't compile.

I hope this helps somebody, or perhaps it might spark some further discussion or give Aren an "ah-ha" moment.... :)

Shifty Geezer

  • Full Member
  • ***
  • Thank You
  • -Given: 7
  • -Receive: 9
  • Posts: 221
    • View Profile
Re: Rare PITA (maybe bug) with ALL NGUI prefabs losing data
« Reply #1 on: June 18, 2017, 07:37:32 AM »
I've closed projects with uncompiled code with errors and not lost anything. When I open them, NGUI doesn't initialise - nothing initialises because the code can't build! I fix my code and the whole thing compiles including NGUI scripts and everything works fine.

Zyxil

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 37
    • View Profile
Re: Rare PITA (maybe bug) with ALL NGUI prefabs losing data
« Reply #2 on: June 18, 2017, 08:40:14 AM »
I may have not nailed down the cause.  This was my current guess.  The event is quite rare and not something I want to experiment with.   ::)

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 316
  • -Receive: 1149
  • Posts: 22,027
  • Toronto, Canada
    • View Profile
Re: Rare PITA (maybe bug) with ALL NGUI prefabs losing data
« Reply #3 on: June 18, 2017, 07:34:19 PM »
It's nothing specific to NGUI, just how Unity works. If there is a compilation error, Unity can't compile the source files, and thus there are no editor classes either -- so no custom class tabs. This is why I always save my window layouts: Window -> Layouts -> Save Layout

Zyxil

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 37
    • View Profile
Re: Rare PITA (maybe bug) with ALL NGUI prefabs losing data
« Reply #4 on: June 18, 2017, 08:26:46 PM »
Yup, that's what I was thinking, too.  Ah well. 

Maybe this post will help somebody save some time.  Recovery is tricky, but doable.