From 52ecc9349cd1cc7dfcf79b741e18b026544feb23 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Fri, 2 Jul 2021 17:44:30 +0200 Subject: [PATCH] [unity] Fixed Timeline and AnimationReferenceAsset in general not updating animations after skeleton asset updated. Closes #1915. --- .../spine-unity/Editor/Utility/AssetUtility.cs | 1 + .../spine-unity/Editor/Utility/DataReloadHandler.cs | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs index cdfc7fe21..1ce022c1c 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs @@ -472,6 +472,7 @@ namespace Spine.Unity.Editor { EditorPrefs.SetString(guid + "_hash", currentHash); } SpineEditorUtilities.DataReloadHandler.ReloadSceneSkeletonComponents(skeletonDataAsset); + SpineEditorUtilities.DataReloadHandler.ReloadAnimationReferenceAssets(skeletonDataAsset); } } } diff --git a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/DataReloadHandler.cs b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/DataReloadHandler.cs index 59da1974c..e14c0dbff 100644 --- a/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/DataReloadHandler.cs +++ b/spine-unity/Assets/Spine/Editor/spine-unity/Editor/Utility/DataReloadHandler.cs @@ -128,6 +128,18 @@ namespace Spine.Unity.Editor { if (sg.isActiveAndEnabled && sg.skeletonDataAsset == skeletonDataAsset) sg.Initialize(true); } } + + public static void ReloadAnimationReferenceAssets (SkeletonDataAsset skeletonDataAsset) { + string[] guids = UnityEditor.AssetDatabase.FindAssets("t:AnimationReferenceAsset"); + foreach (string guid in guids) { + string path = UnityEditor.AssetDatabase.GUIDToAssetPath(guid); + if (!string.IsNullOrEmpty(path)) { + var referenceAsset = UnityEditor.AssetDatabase.LoadAssetAtPath(path); + if (referenceAsset.SkeletonDataAsset == skeletonDataAsset) + referenceAsset.Initialize(); + } + } + } } } }