com.wallstop-studios.unity-helpers 2.0.0-rc81.4 → 2.0.0-rc81.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -161,6 +161,18 @@ namespace WallstopStudios.UnityHelpers.Editor.Sprites
161
161
  public int crunchCompressionLevel = 50;
162
162
 
163
163
  public TextureImporterCompression compression = TextureImporterCompression.Compressed;
164
+
165
+ private void OnValidate()
166
+ {
167
+ if (!Application.isPlaying)
168
+ {
169
+ int removed = spritesToPack.RemoveAll(sprite => sprite == null);
170
+ if (removed > 0)
171
+ {
172
+ EditorUtility.SetDirty(this);
173
+ }
174
+ }
175
+ }
164
176
  }
165
177
  #endif
166
178
  }
@@ -13,6 +13,7 @@ namespace WallstopStudios.UnityHelpers.Editor.Sprites
13
13
  using UnityEditor.U2D;
14
14
  using UnityEngine;
15
15
  using UnityEngine.U2D;
16
+ using WallstopStudios.UnityHelpers.Utils;
16
17
  using Object = UnityEngine.Object;
17
18
 
18
19
  public sealed class ScriptableSpriteAtlasEditor : EditorWindow
@@ -806,9 +807,38 @@ namespace WallstopStudios.UnityHelpers.Editor.Sprites
806
807
  platformSettings.textureCompression = config.compression;
807
808
  atlas.SetPlatformSettings(platformSettings);
808
809
 
809
- Object[] spritesToAdd = config.spritesToPack.Where(s => s != null).ToArray<Object>();
810
- if (spritesToAdd.Length > 0)
810
+ int spriteCount = atlas.spriteCount;
811
+ using PooledResource<Sprite[]> spriteResource = WallstopArrayPool<Sprite>.Get(
812
+ spriteCount
813
+ );
814
+ Sprite[] sprites = spriteResource.resource;
815
+ int loaded = atlas.GetSprites(sprites);
816
+ using PooledResource<List<Sprite>> removeResource = Buffers<Sprite>.List.Get();
817
+ List<Sprite> toRemove = removeResource.resource;
818
+
819
+ for (int i = 0; i < loaded; ++i)
820
+ {
821
+ Sprite sprite = sprites[i];
822
+ if (sprite == null)
823
+ {
824
+ toRemove.Add(sprite);
825
+ }
826
+ }
827
+
828
+ if (toRemove.Count > 0)
829
+ {
830
+ atlas.Remove(toRemove.ToArray<Object>());
831
+ }
832
+
833
+ int removed = config.spritesToPack.RemoveAll(sprite => sprite == null);
834
+ if (removed > 0)
835
+ {
836
+ EditorUtility.SetDirty(config);
837
+ }
838
+
839
+ if (config.spritesToPack.Count > 0)
811
840
  {
841
+ Object[] spritesToAdd = config.spritesToPack.ToArray<Object>();
812
842
  atlas.Add(spritesToAdd);
813
843
  }
814
844
  else
@@ -833,7 +863,7 @@ namespace WallstopStudios.UnityHelpers.Editor.Sprites
833
863
  AssetDatabase.Refresh();
834
864
  }
835
865
  this.Log(
836
- $"'{config.name}': Successfully generated/updated at {outputPath}. Sprites included: {spritesToAdd.Length}."
866
+ $"'{config.name}': Successfully generated/updated at {outputPath}. Sprites included: {config.spritesToPack.Count}."
837
867
  );
838
868
  }
839
869
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.wallstop-studios.unity-helpers",
3
- "version": "2.0.0-rc81.4",
3
+ "version": "2.0.0-rc81.6",
4
4
  "displayName": "Unity Helpers",
5
5
  "description": "Various Unity Helper Library",
6
6
  "dependencies": {},