mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 15:24:55 +08:00
[unity] Fixed SkeletonDataAsset auto-update mechanism on .json file change for both scene view and inspector. Closes #1330.
This commit is contained in:
parent
470c2f5953
commit
bf93b00e6b
@ -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;
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user