Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: Nicki on July 11, 2017, 02:59:55 AM

Title: QoL change for NGUI atlasmaking
Post by: Nicki on July 11, 2017, 02:59:55 AM
If you change line 112 in UIAtlasMaker.GetSelectedTextures from
  1. Object[] objects = EditorUtility.CollectDependencies(Selection.objects);
to
  1. Object[] objects = Selection.GetFiltered(typeof(Texture), SelectionMode.DeepAssets);

you can now add all the sprites in a subfolder to your atlas, rather than having to select them individually.

Do bear in mind, that if you have duplicates, it will "crash" the atlasmaker window, so don't select root. This is the same behavior as is now, if you select two sprites with the same name, so not a big deal though.
Title: Re: QoL change for NGUI atlasmaking
Post by: ArenMook on July 15, 2017, 06:14:54 AM
I'm guessing it won't crash if you do this though, right?
  1.         List<Texture> GetSelectedTextures ()
  2.         {
  3.                 var textures = new List<Texture>();
  4.                 var names = new List<string>();
  5.  
  6.                 if (Selection.objects != null && Selection.objects.Length > 0)
  7.                 {
  8.                         var objects = Selection.GetFiltered(typeof(Texture), SelectionMode.DeepAssets);
  9.  
  10.                         foreach (Object o in objects)
  11.                         {
  12.                                 var tex = o as Texture;
  13.                                 if (tex == null || tex.name == "Font Texture") continue;
  14.                                 if (names.Contains(tex.name)) continue;
  15.  
  16.                                 if (NGUISettings.atlas == null || NGUISettings.atlas.texture != tex)
  17.                                 {
  18.                                         names.Add(tex.name);
  19.                                         textures.Add(tex);
  20.                                 }
  21.                         }
  22.                 }
  23.                 return textures;
  24.         }