Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: AGB on April 10, 2014, 03:02:37 PM

Title: Atlas reference problem
Post by: AGB 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. :(
Title: Re: Atlas reference problem
Post by: ArenMook 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.
Title: Re: Atlas reference problem
Post by: AGB 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).
Title: Re: Atlas reference problem
Post by: ArenMook 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.         }
Title: Re: Atlas reference problem
Post by: AGB 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.
Title: Re: Atlas reference problem
Post by: ArenMook 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.         }