From 400df01dc350934e7333c1503ea380d4f8944279 Mon Sep 17 00:00:00 2001 From: ruccho Date: Sat, 17 Feb 2024 15:58:47 +0900 Subject: [PATCH] fix assets don't saved propery after generation / clearing in 2022.3 --- .../Editor/FangAutoTileEditor.cs | 6 ++---- .../Editor/FangAutoTilePackerEditor.cs | 8 +++++--- .../com.ruccho.fang-auto-tile/Runtime/FangAutoTile.cs | 4 ++-- Packages/com.ruccho.fang-auto-tile/package.json | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Packages/com.ruccho.fang-auto-tile/Editor/FangAutoTileEditor.cs b/Packages/com.ruccho.fang-auto-tile/Editor/FangAutoTileEditor.cs index 82a2ff8..dd47efc 100644 --- a/Packages/com.ruccho.fang-auto-tile/Editor/FangAutoTileEditor.cs +++ b/Packages/com.ruccho.fang-auto-tile/Editor/FangAutoTileEditor.cs @@ -335,11 +335,10 @@ private void Generate() } finally { + serializedObject.ApplyModifiedProperties(); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target)); - - serializedObject.ApplyModifiedProperties(); } } @@ -365,11 +364,10 @@ private void Clear() } */ + serializedObject.ApplyModifiedProperties(); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); - AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target)); - serializedObject.ApplyModifiedProperties(); } public void GenerateCombination() diff --git a/Packages/com.ruccho.fang-auto-tile/Editor/FangAutoTilePackerEditor.cs b/Packages/com.ruccho.fang-auto-tile/Editor/FangAutoTilePackerEditor.cs index 2332165..60507db 100644 --- a/Packages/com.ruccho.fang-auto-tile/Editor/FangAutoTilePackerEditor.cs +++ b/Packages/com.ruccho.fang-auto-tile/Editor/FangAutoTilePackerEditor.cs @@ -23,6 +23,8 @@ public override void OnInspectorGUI() public override Texture2D RenderStaticPreview(string assetPath, Object[] subAssets, int width, int height) { var compiledChannelsProp = serializedObject.FindProperty("compiledChannels"); + if (compiledChannelsProp.arraySize == 0) return base.RenderStaticPreview(assetPath, subAssets, width, height); + var channelProp = compiledChannelsProp.GetArrayElementAtIndex(0); if (channelProp != null) @@ -183,18 +185,18 @@ private void Generate() FangAutoTileEditor.GenerateTilesForTexture(dest, segmentsOrdered, false); } + serializedObject.ApplyModifiedProperties(); + AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); foreach (var e in editors) { - AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(e.target)); e.serializedObject.ApplyModifiedProperties(); + AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(e.target)); } AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target)); - - serializedObject.ApplyModifiedProperties(); } } } \ No newline at end of file diff --git a/Packages/com.ruccho.fang-auto-tile/Runtime/FangAutoTile.cs b/Packages/com.ruccho.fang-auto-tile/Runtime/FangAutoTile.cs index 12cd072..424ac4c 100644 --- a/Packages/com.ruccho.fang-auto-tile/Runtime/FangAutoTile.cs +++ b/Packages/com.ruccho.fang-auto-tile/Runtime/FangAutoTile.cs @@ -81,9 +81,9 @@ public enum FrameModeType public IEnumerable GetAllSprites() { var spritesFromCombinations = combinations?.SelectMany(c => c.Frames) ?? Enumerable.Empty(); - var spritesFromSlopes = slopeDefinition.Sizes?.SelectMany(s => s.GetAngles()) + var spritesFromSlopes = slopeDefinition?.Sizes?.SelectMany(s => s.GetAngles()) .SelectMany(a => a.GetTileDefinitions()).SelectMany(tileDefs => tileDefs) - .SelectMany(tileDef => tileDef.Frames); + .SelectMany(tileDef => tileDef.Frames) ?? Enumerable.Empty(); return spritesFromCombinations.Concat(spritesFromSlopes); } diff --git a/Packages/com.ruccho.fang-auto-tile/package.json b/Packages/com.ruccho.fang-auto-tile/package.json index 4c18fd8..03fd55f 100644 --- a/Packages/com.ruccho.fang-auto-tile/package.json +++ b/Packages/com.ruccho.fang-auto-tile/package.json @@ -1,6 +1,6 @@ { "name": "com.ruccho.fang-auto-tile", - "version": "3.0.0", + "version": "3.0.1", "displayName": "Fang Auto Tile", "description": "Fang Auto Tile is an extremely easy auto-tiling system.", "unity": "2021.3",