Skip to content

Commit

Permalink
Merge pull request #4 from ruccho/fix/assets_not_saved_properly_2022.3
Browse files Browse the repository at this point in the history
Fix assets don't saved propery after generation / clearing in 2022.3
  • Loading branch information
ruccho authored Feb 17, 2024
2 parents 62dd72b + 400df01 commit 1d322cb
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,10 @@ private void Generate()
}
finally
{
serializedObject.ApplyModifiedProperties();
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();
AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target));

serializedObject.ApplyModifiedProperties();
}
}

Expand All @@ -365,11 +364,10 @@ private void Clear()
}
*/

serializedObject.ApplyModifiedProperties();
AssetDatabase.SaveAssets();
AssetDatabase.Refresh();

AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(target));
serializedObject.ApplyModifiedProperties();
}

public void GenerateCombination()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
}
}
}
4 changes: 2 additions & 2 deletions Packages/com.ruccho.fang-auto-tile/Runtime/FangAutoTile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ public enum FrameModeType
public IEnumerable<Sprite> GetAllSprites()
{
var spritesFromCombinations = combinations?.SelectMany(c => c.Frames) ?? Enumerable.Empty<Sprite>();
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<Sprite>();

return spritesFromCombinations.Concat(spritesFromSlopes);
}
Expand Down
2 changes: 1 addition & 1 deletion Packages/com.ruccho.fang-auto-tile/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 1d322cb

Please sign in to comment.