Skip to content

Commit

Permalink
profiler wrapping
Browse files Browse the repository at this point in the history
  • Loading branch information
Cammin committed May 21, 2024
1 parent e885208 commit fcd2f9d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Assets/LDtkUnity/Editor/ScriptedImporter/LDtkTilesetImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ internal sealed partial class LDtkTilesetImporter : LDtkJsonImporter<LDtkTileset
public const string PIXELS_PER_UNIT = nameof(_pixelsPerUnit);

[SerializeField] internal int _pixelsPerUnit = -1;

/// <summary>
/// Holds onto all the standard grid-sized tiles. This serializes the sprite's changed settings between reimports, like pivot or physics shape.
/// </summary>
Expand Down Expand Up @@ -217,18 +218,24 @@ private LDtkArtifactAssetsTileset MakeAndCacheArtifacts(TextureGenerationOutput
LDtkArtifactAssetsTileset artifacts = ScriptableObject.CreateInstance<LDtkArtifactAssetsTileset>();
artifacts.name = $"_{_definition.Def.Identifier}_Artifacts";

LDtkProfiler.BeginSample("InitArrays");
LDtkProfiler.BeginSample("InitLists");
artifacts._sprites = new List<Sprite>(_sprites.Count);
artifacts._tiles = new List<LDtkTilesetTile>(_sprites.Count);
artifacts._additionalSprites = new List<Sprite>(_additionalTiles.Count);
LDtkProfiler.EndSample();

LDtkProfiler.BeginSample("CustomDataToDictionary");
var customData = _definition.Def.CustomDataToDictionary();
LDtkProfiler.EndSample();

LDtkProfiler.BeginSample("EnumTagsToDictionary");
var enumTags = _definition.Def.EnumTagsToDictionary();
LDtkProfiler.EndSample();

LDtkProfiler.BeginSample("IterateAllSpriteOutput");
for (int i = 0; i < output.sprites.Length; i++)
{
LDtkProfiler.BeginSample("AddTile");
LDtkProfiler.BeginSample("AddSpriteToAsset");
Sprite spr = output.sprites[i];
spr.hideFlags = HideFlags.HideInHierarchy;
ImportContext.AddObjectToAsset(spr.name, spr);
Expand Down Expand Up @@ -264,12 +271,13 @@ private LDtkArtifactAssetsTileset MakeAndCacheArtifacts(TextureGenerationOutput
}
LDtkProfiler.EndSample();

LDtkProfiler.BeginSample("AddTile");
LDtkProfiler.BeginSample("AddTileToAsset");
ImportContext.AddObjectToAsset(newTilesetTile.name, newTilesetTile);
artifacts._sprites.Add(spr);
artifacts._tiles.Add(newTilesetTile);
LDtkProfiler.EndSample();
}
LDtkProfiler.EndSample();

LDtkProfiler.BeginSample("TryParseCustomData");
//process these after all the tiles are created because we might reference other tiles for animation
Expand Down

0 comments on commit fcd2f9d

Please sign in to comment.