mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-06 18:56:54 +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 TargetAssetGUID { get { return AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(targetSkeletonDataAsset)); } }
|
||||||
string LastSkinKey { get { return TargetAssetGUID + "_lastSkin"; } }
|
string LastSkinKey { get { return TargetAssetGUID + "_lastSkin"; } }
|
||||||
string LastSkinName { get { return EditorPrefs.GetString(LastSkinKey, ""); } }
|
string LastSkinName { get { return EditorPrefs.GetString(LastSkinKey, ""); } }
|
||||||
|
|
||||||
void OnEnable () {
|
void OnEnable () {
|
||||||
InitializeEditor();
|
InitializeEditor();
|
||||||
}
|
}
|
||||||
@ -93,6 +93,12 @@ namespace Spine.Unity.Editor {
|
|||||||
OnDestroy();
|
OnDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdateSkeletonData () {
|
||||||
|
preview.Clear();
|
||||||
|
InitializeEditor();
|
||||||
|
EditorUtility.SetDirty(targetSkeletonDataAsset);
|
||||||
|
}
|
||||||
|
|
||||||
void InitializeEditor () {
|
void InitializeEditor () {
|
||||||
SpineEditorUtilities.ConfirmInitialization();
|
SpineEditorUtilities.ConfirmInitialization();
|
||||||
targetSkeletonDataAsset = (SkeletonDataAsset)target;
|
targetSkeletonDataAsset = (SkeletonDataAsset)target;
|
||||||
|
|||||||
@ -800,6 +800,12 @@ namespace Spine.Unity.Editor {
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SkeletonDataAssetInspector[] skeletonDataInspectors = Resources.FindObjectsOfTypeAll<SkeletonDataAssetInspector>();
|
||||||
|
foreach (var inspector in skeletonDataInspectors) {
|
||||||
|
inspector.UpdateSkeletonData();
|
||||||
|
}
|
||||||
|
|
||||||
// Any post processing of images
|
// Any post processing of images
|
||||||
|
|
||||||
// Under some circumstances (e.g. on first import) SkeletonGraphic objects
|
// Under some circumstances (e.g. on first import) SkeletonGraphic objects
|
||||||
@ -818,7 +824,7 @@ namespace Spine.Unity.Editor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ReloadSkeletonData (string skeletonJSONPath) {
|
static void ReloadSkeletonData (string skeletonJSONPath) {
|
||||||
string dir = Path.GetDirectoryName(skeletonJSONPath);
|
string dir = Path.GetDirectoryName(skeletonJSONPath);
|
||||||
TextAsset textAsset = AssetDatabase.LoadAssetAtPath<TextAsset>(skeletonJSONPath);
|
TextAsset textAsset = AssetDatabase.LoadAssetAtPath<TextAsset>(skeletonJSONPath);
|
||||||
@ -870,6 +876,7 @@ namespace Spine.Unity.Editor {
|
|||||||
if (currentHash != null)
|
if (currentHash != null)
|
||||||
EditorPrefs.SetString(guid + "_hash", currentHash);
|
EditorPrefs.SetString(guid + "_hash", currentHash);
|
||||||
}
|
}
|
||||||
|
DataReloadHandler.ReloadSceneSkeletonComponents(skeletonDataAsset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user