wuxianshengcong/Library/PackageCache/com.unity.2d.aseprite@1.1.6/Editor/Tasks/ImportMergedLayers.cs

33 lines
1.1 KiB
C#
Raw Normal View History

2024-12-30 12:56:27 +08:00
using System.Collections.Generic;
using Unity.Collections;
using Unity.Mathematics;
using UnityEngine;
namespace UnityEditor.U2D.Aseprite
{
internal static class ImportMergedLayers
{
public static void Import(string assetName, ref List<Layer> layers, out List<NativeArray<Color32>> cellBuffers, out List<int2> cellSize)
{
var cellsPerFrame = CellTasks.GetAllCellsPerFrame(in layers);
var mergedCells = CellTasks.MergeCells(in cellsPerFrame, assetName);
CellTasks.CollectDataFromCells(mergedCells, out cellBuffers, out cellSize);
UpdateLayerList(mergedCells, assetName, ref layers);
}
static void UpdateLayerList(IReadOnlyList<Cell> cells, string assetName, ref List<Layer> layers)
{
layers.Clear();
var flattenLayer = new Layer()
{
cells = new List<Cell>(cells),
index = 0,
name = assetName
};
flattenLayer.guid = Layer.GenerateGuid(flattenLayer);
layers.Add(flattenLayer);
}
}
}