Merge branch '3.6' into 3.7-beta

This commit is contained in:
pharan 2018-05-29 12:47:18 +08:00
commit b7da77b894
2 changed files with 32 additions and 12 deletions

View File

@ -651,7 +651,12 @@ namespace Spine.Unity.Editor {
SkeletonAnimation skeletonAnimation; SkeletonAnimation skeletonAnimation;
GameObject previewGameObject; GameObject previewGameObject;
internal bool requiresRefresh; internal bool requiresRefresh;
#if !(UNITY_2017_4 || UNITY_2018)
float animationLastTime; float animationLastTime;
#endif
static float CurrentTime { get { return (float)EditorApplication.timeSinceStartup; } }
Action Repaint; Action Repaint;
public event Action<string> OnSkinChanged; public event Action<string> OnSkinChanged;
@ -742,7 +747,9 @@ namespace Spine.Unity.Editor {
if (previewRenderUtility == null) { if (previewRenderUtility == null) {
previewRenderUtility = new PreviewRenderUtility(true); previewRenderUtility = new PreviewRenderUtility(true);
animationLastTime = Time.realtimeSinceStartup; #if !(UNITY_2017_4 || UNITY_2018)
animationLastTime = CurrentTime;
#endif
const int PreviewLayer = 30; const int PreviewLayer = 30;
const int PreviewCameraCullingMask = 1 << PreviewLayer; const int PreviewCameraCullingMask = 1 << PreviewLayer;
@ -770,6 +777,10 @@ namespace Spine.Unity.Editor {
skeletonAnimation.initialSkinName = skinName; skeletonAnimation.initialSkinName = skinName;
skeletonAnimation.LateUpdate(); skeletonAnimation.LateUpdate();
previewGameObject.GetComponent<Renderer>().enabled = false; previewGameObject.GetComponent<Renderer>().enabled = false;
#if UNITY_2017_4 || UNITY_2018
previewRenderUtility.AddSingleGO(previewGameObject);
#endif
} }
if (this.ActiveTrack != null) cameraAdjustEndFrame = EditorApplication.timeSinceStartup + skeletonAnimation.AnimationState.GetCurrent(0).Alpha; if (this.ActiveTrack != null) cameraAdjustEndFrame = EditorApplication.timeSinceStartup + skeletonAnimation.AnimationState.GetCurrent(0).Alpha;
@ -813,6 +824,7 @@ namespace Spine.Unity.Editor {
previewRenderUtility.BeginStaticPreview(new Rect(0, 0, width, height)); previewRenderUtility.BeginStaticPreview(new Rect(0, 0, width, height));
DoRenderPreview(false); DoRenderPreview(false);
var tex = previewRenderUtility.EndStaticPreview(); var tex = previewRenderUtility.EndStaticPreview();
return tex; return tex;
} }
@ -825,12 +837,17 @@ namespace Spine.Unity.Editor {
var renderer = go.GetComponent<Renderer>(); var renderer = go.GetComponent<Renderer>();
renderer.enabled = true; renderer.enabled = true;
if (!EditorApplication.isPlaying) {
skeletonAnimation.Update((Time.realtimeSinceStartup - animationLastTime));
skeletonAnimation.LateUpdate();
animationLastTime = Time.realtimeSinceStartup;
}
if (!EditorApplication.isPlaying) {
#if !(UNITY_2017_4 || UNITY_2018)
float current = CurrentTime;
float deltaTime = (current - animationLastTime);
skeletonAnimation.Update(deltaTime);
animationLastTime = current;
#endif
skeletonAnimation.LateUpdate();
}
var thisPreviewUtilityCamera = this.PreviewUtilityCamera; var thisPreviewUtilityCamera = this.PreviewUtilityCamera;
if (drawHandles) { if (drawHandles) {
@ -861,7 +878,7 @@ namespace Spine.Unity.Editor {
if (previewRenderUtility == null) if (previewRenderUtility == null)
return; return;
if (EditorApplication.timeSinceStartup < cameraAdjustEndFrame) if (CurrentTime < cameraAdjustEndFrame)
AdjustCameraGoals(); AdjustCameraGoals();
lastCameraPositionGoal = cameraPositionGoal; lastCameraPositionGoal = cameraPositionGoal;

View File

@ -50,9 +50,9 @@ namespace Spine.Unity.Playables {
var state = spineComponent.AnimationState; var state = spineComponent.AnimationState;
if (!Application.isPlaying) { if (!Application.isPlaying) {
#if SPINE_EDITMODEPOSE #if SPINE_EDITMODEPOSE
PreviewEditModePose(playable, spineComponent); PreviewEditModePose(playable, spineComponent);
#endif #endif
return; return;
} }
@ -81,7 +81,6 @@ namespace Spine.Unity.Playables {
if (clipData.animationReference == null) { if (clipData.animationReference == null) {
float mixDuration = clipData.customDuration ? clipData.mixDuration : state.Data.DefaultMix; float mixDuration = clipData.customDuration ? clipData.mixDuration : state.Data.DefaultMix;
state.SetEmptyAnimation(0, mixDuration); state.SetEmptyAnimation(0, mixDuration);
continue;
} else { } else {
if (clipData.animationReference.Animation != null) { if (clipData.animationReference.Animation != null) {
Spine.TrackEntry trackEntry = state.SetAnimation(0, clipData.animationReference.Animation, clipData.loop); Spine.TrackEntry trackEntry = state.SetAnimation(0, clipData.animationReference.Animation, clipData.loop);
@ -96,11 +95,15 @@ namespace Spine.Unity.Playables {
} }
//else Debug.LogWarningFormat("Animation named '{0}' not found", clipData.animationName); //else Debug.LogWarningFormat("Animation named '{0}' not found", clipData.animationName);
} }
// Ensure that the first frame ends with an updated mesh.
spineComponent.Update(0);
spineComponent.LateUpdate();
} }
} }
} }
#if SPINE_EDITMODEPOSE #if SPINE_EDITMODEPOSE
public void PreviewEditModePose (Playable playable, SkeletonAnimation spineComponent) { public void PreviewEditModePose (Playable playable, SkeletonAnimation spineComponent) {
if (Application.isPlaying) return; if (Application.isPlaying) return;
if (spineComponent == null) return; if (spineComponent == null) return;
@ -160,7 +163,7 @@ namespace Spine.Unity.Playables {
// Do nothing outside of the first clip and the last clip. // Do nothing outside of the first clip and the last clip.
} }
#endif #endif
} }