[unity] Fixed SkeletonDataAsset auto-update mechanism on .json file change for both scene view and inspector. Closes #1330.

This commit is contained in:
Harald Csaszar 2019-04-18 19:53:03 +02:00
parent 470c2f5953
commit bf93b00e6b
2 changed files with 15 additions and 2 deletions

View File

@ -78,7 +78,7 @@ namespace Spine.Unity.Editor {
string TargetAssetGUID { get { return AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(targetSkeletonDataAsset)); } }
string LastSkinKey { get { return TargetAssetGUID + "_lastSkin"; } }
string LastSkinName { get { return EditorPrefs.GetString(LastSkinKey, ""); } }
void OnEnable () {
InitializeEditor();
}
@ -93,6 +93,12 @@ namespace Spine.Unity.Editor {
OnDestroy();
}
public void UpdateSkeletonData () {
preview.Clear();
InitializeEditor();
EditorUtility.SetDirty(targetSkeletonDataAsset);
}
void InitializeEditor () {
SpineEditorUtilities.ConfirmInitialization();
targetSkeletonDataAsset = (SkeletonDataAsset)target;

View File

@ -800,6 +800,12 @@ namespace Spine.Unity.Editor {
break;
#endif
}
SkeletonDataAssetInspector[] skeletonDataInspectors = Resources.FindObjectsOfTypeAll<SkeletonDataAssetInspector>();
foreach (var inspector in skeletonDataInspectors) {
inspector.UpdateSkeletonData();
}
// Any post processing of images
// Under some circumstances (e.g. on first import) SkeletonGraphic objects
@ -818,7 +824,7 @@ namespace Spine.Unity.Editor {
}
}
}
static void ReloadSkeletonData (string skeletonJSONPath) {
string dir = Path.GetDirectoryName(skeletonJSONPath);
TextAsset textAsset = AssetDatabase.LoadAssetAtPath<TextAsset>(skeletonJSONPath);
@ -870,6 +876,7 @@ namespace Spine.Unity.Editor {
if (currentHash != null)
EditorPrefs.SetString(guid + "_hash", currentHash);
}
DataReloadHandler.ReloadSceneSkeletonComponents(skeletonDataAsset);
}
}
}