Merge branch '3.8' into 3.9-beta

This commit is contained in:
Harald Csaszar 2020-03-23 13:49:53 +01:00
commit 5eddac05ac
4 changed files with 29 additions and 7 deletions

View File

@ -1008,7 +1008,7 @@ namespace Spine.Unity.Editor {
newSkeletonAnimation.Initialize(false);
} catch (System.Exception e) {
if (destroyInvalid) {
Debug.LogWarning("Editor-instantiated SkeletonAnimation threw an Exception. Destroying GameObject to prevent orphaned GameObject.", skeletonDataAsset);
Debug.LogWarning("Editor-instantiated SkeletonAnimation threw an Exception. Destroying GameObject to prevent orphaned GameObject.\n" + e.Message, skeletonDataAsset);
GameObject.DestroyImmediate(go);
}
throw e;

View File

@ -52,6 +52,7 @@ namespace Spine.Unity {
/// This is the Spine.AnimationState object of this SkeletonAnimation. You can control animations through it.
/// Note that this object, like .skeleton, is not guaranteed to exist in Awake. Do all accesses and caching to it in Start</summary>
public Spine.AnimationState AnimationState { get { return this.state; } }
private bool wasUpdatedAfterInit = true;
#endregion
#region Bone Callbacks ISkeletonAnimation
@ -149,13 +150,12 @@ namespace Spine.Unity {
public override void Initialize (bool overwrite) {
if (valid && !overwrite)
return;
base.Initialize(overwrite);
if (!valid)
return;
state = new Spine.AnimationState(skeletonDataAsset.GetAnimationStateData());
wasUpdatedAfterInit = false;
if (!string.IsNullOrEmpty(_animationName)) {
var animationObject = skeletonDataAsset.GetSkeletonData(false).FindAnimation(_animationName);
@ -203,8 +203,14 @@ namespace Spine.Unity {
if (_UpdateComplete != null) {
_UpdateComplete(this);
}
wasUpdatedAfterInit = true;
}
public override void LateUpdate () {
// instantiation can happen from Update() after this component, leading to a missing Update() call.
if (!wasUpdatedAfterInit) Update(0);
base.LateUpdate();
}
}
}

View File

@ -59,6 +59,7 @@ namespace Spine.Unity {
public bool freeze;
public bool unscaledTime;
private bool wasUpdatedAfterInit = true;
private Texture baseTexture = null;
#if UNITY_EDITOR
@ -212,9 +213,12 @@ namespace Spine.Unity {
}
if (UpdateComplete != null) UpdateComplete(this);
wasUpdatedAfterInit = true;
}
public void LateUpdate () {
// instantiation can happen from Update() after this component, leading to a missing Update() call.
if (!wasUpdatedAfterInit) Update(0);
if (freeze) return;
//this.SetVerticesDirty(); // Which is better?
UpdateMesh();
@ -313,6 +317,7 @@ namespace Spine.Unity {
if (!string.IsNullOrEmpty(initialSkinName))
skeleton.SetSkin(initialSkinName);
wasUpdatedAfterInit = false;
if (!string.IsNullOrEmpty(startingAnimation)) {
var animationObject = skeletonDataAsset.GetSkeletonData(false).FindAnimation(startingAnimation);
if (animationObject != null) {
@ -321,8 +326,6 @@ namespace Spine.Unity {
if (!Application.isPlaying)
Update(0f);
#endif
if (freeze)
Update(0f);
}
}

View File

@ -36,6 +36,7 @@ namespace Spine.Unity {
[SerializeField] protected MecanimTranslator translator;
public MecanimTranslator Translator { get { return translator; } }
private bool wasUpdatedAfterInit = true;
#region Bone Callbacks (ISkeletonAnimation)
protected event UpdateBonesDelegate _UpdateLocal;
@ -61,12 +62,17 @@ namespace Spine.Unity {
#endregion
public override void Initialize (bool overwrite) {
if (valid && !overwrite) return;
if (valid && !overwrite)
return;
base.Initialize(overwrite);
if (!valid) return;
if (!valid)
return;
if (translator == null) translator = new MecanimTranslator();
translator.Initialize(GetComponent<Animator>(), this.skeletonDataAsset);
wasUpdatedAfterInit = false;
}
public void Update () {
@ -106,6 +112,13 @@ namespace Spine.Unity {
if (_UpdateComplete != null)
_UpdateComplete(this);
}
wasUpdatedAfterInit = true;
}
public override void LateUpdate () {
// instantiation can happen from Update() after this component, leading to a missing Update() call.
if (!wasUpdatedAfterInit) Update();
base.LateUpdate();
}
[System.Serializable]