Author Topic: Can't traverse all atlases  (Read 1592 times)

S3dition

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Can't traverse all atlases
« 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.

  • All atlases are called from the same class.
  • All atlases are stored in the same exact resources folder.
  • The same exact atlases don't appear every time - it's not random.
  • I've deleted and recreated the atlases.
  • Atlases work fine if I set them in the inspector.
  • The non-working atlases return null when I try to find them using code.

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

« Last Edit: January 27, 2014, 04:38:08 PM by S3dition »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Can't traverse all atlases
« Reply #1 on: January 27, 2014, 06:40:11 PM »
You need to Resources.Load the atlas. What do you use?

S3dition

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Can't traverse all atlases
« Reply #2 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.                                                                 }

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Can't traverse all atlases
« Reply #3 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;