Skip to content

Commit

Permalink
for dev project, installed the aseprite importer to test easier, and …
Browse files Browse the repository at this point in the history
…the older unity versions will still work correctly
  • Loading branch information
Cammin committed May 26, 2024
1 parent da23853 commit 46f82ba
Show file tree
Hide file tree
Showing 5 changed files with 402 additions and 9 deletions.
14 changes: 7 additions & 7 deletions Assets/LDtkUnity/Editor/ScriptedImporter/LDtkTilesetImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
using UnityEngine.Tilemaps;
using Debug = UnityEngine.Debug;

#if LDTK_UNITY_ASEPRITE
#if LDTK_UNITY_ASEPRITE && UNITY_2021_3_OR_NEWER
using UnityEditor.U2D.Aseprite;
#endif

Expand Down Expand Up @@ -61,7 +61,7 @@ internal sealed partial class LDtkTilesetImporter : LDtkJsonImporter<LDtkTileset
private LDtkTilesetDefinitionWrapper _definition;
private TilesetDefinition _json;

#if LDTK_UNITY_ASEPRITE
#if LDTK_UNITY_ASEPRITE && UNITY_2021_3_OR_NEWER
private AsepriteImporter _srcAsepriteImporter;
#endif
private TextureImporter _srcTextureImporter;
Expand Down Expand Up @@ -538,7 +538,7 @@ private bool PrepareGenerate(TextureImporterPlatformSettings platformSettings, o

TextureImporterSettings importerSettings = new TextureImporterSettings();

#if LDTK_UNITY_ASEPRITE
#if LDTK_UNITY_ASEPRITE && UNITY_2021_3_OR_NEWER
if (_srcAsepriteImporter)
{
_srcAsepriteImporter.ReadTextureSettings(importerSettings);
Expand All @@ -562,7 +562,7 @@ private bool PrepareGenerate(TextureImporterPlatformSettings platformSettings, o

Texture2D copy;

#if LDTK_UNITY_ASEPRITE
#if LDTK_UNITY_ASEPRITE && UNITY_2021_3_OR_NEWER
if (_srcAsepriteImporter)
{
Sprite sprite = AssetDatabase.LoadAssetAtPath<Sprite>(PathToTexture(assetPath));
Expand Down Expand Up @@ -628,7 +628,7 @@ private Texture2D GenerateTextureFromAseprite(Sprite sprite)

private TextureImporterPlatformSettings GetTextureImporterPlatformSettings()
{
#if LDTK_UNITY_ASEPRITE
#if LDTK_UNITY_ASEPRITE && UNITY_2021_3_OR_NEWER
if (_srcAsepriteImporter)
{
return _srcAsepriteImporter.GetImporterPlatformSettings(EditorUserBuildSettings.activeBuildTarget);
Expand Down Expand Up @@ -708,7 +708,7 @@ private bool CacheTextureImporterOrAsepriteImporter()
//Then check aseprite
if (LDtkRelativeGetterTilesetTexture.IsAsepriteAsset(path))
{
#if LDTK_UNITY_ASEPRITE
#if LDTK_UNITY_ASEPRITE && UNITY_2021_3_OR_NEWER
_srcAsepriteImporter = (AsepriteImporter)GetAtPath(path);
if (_srcAsepriteImporter == null)
{
Expand Down Expand Up @@ -801,7 +801,7 @@ private void ForceUpdateSpriteDataName(SpriteRect spr)
private static readonly int[] MaxSizes = new[] { 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384 };
private bool HasTextureIssue(TextureImporterPlatformSettings platformSettings)
{
#if LDTK_UNITY_ASEPRITE
#if LDTK_UNITY_ASEPRITE && UNITY_2021_3_OR_NEWER
AssetImporter importer = _srcAsepriteImporter != null ? (AssetImporter)_srcAsepriteImporter : _srcTextureImporter;
#else
AssetImporter importer = _srcTextureImporter;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 46f82ba

Please sign in to comment.