Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: S3dition on January 27, 2014, 12:51:59 PM

Title: Can't traverse all atlases
Post by: S3dition on January 27, 2014, 12:51:59 PM
I'm having problems setting the atlas I need dynamically. It works for about 25% of the atlases.


I've tried changing to a non-working atlas specifically in the code, but it can't seem to find them.

Title: Re: Can't traverse all atlases
Post by: ArenMook on January 27, 2014, 06:40:11 PM
You need to Resources.Load the atlas. What do you use?
Title: Re: Can't traverse all atlases
Post by: S3dition on January 27, 2014, 09:38:38 PM
This works, just not on specific atlases. As stated above, other atlases in the same exact folder, called the same exact way, work perfectly fine.

  1. foreach (Mech mech in mechDataScript.Mechs) {
  2.                                                                 GameObject newMech = NGUITools.AddChild (MechGrid, MechPrefab);
  3.                                                                 newMech.name = mech.Name + " " + mech.variant;
  4.                                                                 newMech.GetComponent<MechCard> ().mech = mech;
  5.                                                                 newMech.layer = 8;
  6.                                                                 newMech.transform.FindChild ("LabelMechName").GetComponent<UILabel> ().text = newMech.name;
  7.  
  8.                                                                 mech.mechAtlas = Resources.Load ("Atlas/" + mech.Name) as GameObject;
  9.                                                                
  10.                                                                 Debug.Log (mech.Name);
  11.                                                                 if (mech.mechAtlas != null) {
  12.                                                                                
  13.                                                                                 newMech.transform.FindChild ("MechThumb").GetComponent<UISprite> ().atlas = mech.mechAtlas.GetComponent<UIAtlas> ();
  14.                                                                                 newMech.transform.FindChild ("MechThumb").GetComponent<UISprite> ().spriteName = mech.Id.ToString ();
  15.                                                                 }
Title: Re: Can't traverse all atlases
Post by: ArenMook on January 28, 2014, 09:21:57 AM
I suggest checking the Unity's documentation for Resources.Load. If the loading fails, then you likely didn't specify the name it can resolve. It's not an NGUI function after all.
  1. mech.mechAtlas = Resources.Load ("Atlas/" + mech.Name) as GameObject;