Author Topic: Atlas reference problem  (Read 6384 times)

AGB

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 74
    • View Profile
    • Steam Defense
Atlas reference problem
« on: April 10, 2014, 03:02:37 PM »
When atlas was normal atlas, and then switched to Reference, it still "contains" reference to old textures, materials and objects (They are saved in prefab).  And includes them in build. :(
I'm a busy man... I have places to go,monsters to kill...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Atlas reference problem
« Reply #1 on: April 11, 2014, 07:14:04 AM »
An atlas only references 1 material. It doesn't reference any textures. If you want it to be safe, delete the unused material in Unity.

AGB

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 74
    • View Profile
    • Steam Defense
Re: Atlas reference problem
« Reply #2 on: April 21, 2014, 03:03:45 PM »
I dont want to delete material. i want to drop link between it and my Atlas, when making atlas as Reference. Will try latest NGUI version, maybe this will help?
- Added [NonSerialized] next to private variables. Unity apparently serialized private variables in prefabs (sigh).
I'm a busy man... I have places to go,monsters to kill...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Atlas reference problem
« Reply #3 on: April 22, 2014, 04:28:35 AM »
UIAtlas.material is a serialized field, so I don't think that change would be related. However, changing UIAtlas.replacement to this might:
  1.         public UIAtlas replacement
  2.         {
  3.                 get
  4.                 {
  5.                         return mReplacement;
  6.                 }
  7.                 set
  8.                 {
  9.                         UIAtlas rep = value;
  10.                         if (rep == this) rep = null;
  11.  
  12.                         if (mReplacement != rep)
  13.                         {
  14.                                 if (rep != null && rep.replacement == this) rep.replacement = null;
  15.                                 if (mReplacement != null) MarkAsChanged();
  16.                                 mReplacement = rep;
  17.                                 if (rep != null) material = null; // <-- this right here
  18.                                 MarkAsChanged();
  19.                         }
  20.                 }
  21.         }

AGB

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 74
    • View Profile
    • Steam Defense
Re: Atlas reference problem
« Reply #4 on: May 09, 2014, 05:26:34 AM »
Thanks! Same problem happens with Font, when it was BitmapFont, but then switched to "Reference" font - BitmapFont variables stay there.
I'm a busy man... I have places to go,monsters to kill...

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Atlas reference problem
« Reply #5 on: May 09, 2014, 06:09:45 AM »
Thanks, I'll fix it there too. This should do it.
  1.         public UIFont replacement
  2.         {
  3.                 get
  4.                 {
  5.                         return mReplacement;
  6.                 }
  7.                 set
  8.                 {
  9.                         UIFont rep = value;
  10.                         if (rep == this) rep = null;
  11.  
  12.                         if (mReplacement != rep)
  13.                         {
  14.                                 if (rep != null && rep.replacement == this) rep.replacement = null;
  15.                                 if (mReplacement != null) MarkAsChanged();
  16.                                 mReplacement = rep;
  17.  
  18.                                 if (rep != null)
  19.                                 {
  20.                                         mPMA = -1;
  21.                                         mMat = null;
  22.                                         mFont = null;
  23.                                         mDynamicFont = null;
  24.                                 }
  25.                                 MarkAsChanged();
  26.                         }
  27.                 }
  28.         }