No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ImportLayers.cs 1.3KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System.Collections.Generic;
  2. using Unity.Collections;
  3. using UnityEngine;
  4. namespace UnityEditor.U2D.Aseprite
  5. {
  6. internal static class ImportLayers
  7. {
  8. public static void Import(List<Layer> layers, out List<NativeArray<Color32>> cellBuffers, out List<int> cellWidth, out List<int> cellHeight)
  9. {
  10. cellBuffers = new List<NativeArray<Color32>>();
  11. cellWidth = new List<int>();
  12. cellHeight = new List<int>();
  13. for (var i = 0; i < layers.Count; ++i)
  14. {
  15. var cells = layers[i].cells;
  16. for (var m = 0; m < cells.Count; ++m)
  17. {
  18. var width = cells[m].cellRect.width;
  19. var height = cells[m].cellRect.height;
  20. if (width == 0 || height == 0)
  21. continue;
  22. cellBuffers.Add(cells[m].image);
  23. cellWidth.Add(width);
  24. cellHeight.Add(height);
  25. }
  26. }
  27. for (var i = 0; i < cellBuffers.Count; ++i)
  28. {
  29. var buffer = cellBuffers[i];
  30. TextureTasks.FlipTextureY(ref buffer, cellWidth[i], cellHeight[i]);
  31. cellBuffers[i] = buffer;
  32. }
  33. }
  34. }
  35. }