validate animation state in editor (#3027)

This commit is contained in:
Jare Guo
2018-07-30 12:47:49 +08:00
committed by pandamicro
parent 74b38f2f99
commit 61fe786148
+24 -18
View File
@@ -274,8 +274,10 @@ function refreshScene () {
if (nowPreviewing) {
animationState.animatedSinceLastFrame = true;
let component = cc.engine.getInstanceById(AnimUtils.Cache.component);
let animation = component.getAnimationState(AnimUtils.Cache.animation);
animationState.time = animation.time;
if (component) {
let animation = component.getAnimationState(AnimUtils.Cache.animation);
animationState.time = animation.time;
}
}
else {
animationState.animatedSinceLastFrame = false;
@@ -283,10 +285,12 @@ function refreshScene () {
}
else if (nowPreviewing) {
let component = cc.engine.getInstanceById(AnimUtils.Cache.component);
let animation = component.getAnimationState(AnimUtils.Cache.animation);
if (animationState.time !== animation.time) {
animationState.animatedSinceLastFrame = true;
animationState.time = AnimUtils.Cache.animation.time;
if (component) {
let animation = component.getAnimationState(AnimUtils.Cache.animation);
if (animationState.time !== animation.time) {
animationState.animatedSinceLastFrame = true;
animationState.time = AnimUtils.Cache.animation.time;
}
}
}
}
@@ -307,18 +311,20 @@ function refreshScene () {
(AnimUtils = Editor.require('scene://utils/animation')) &&
AnimUtils.Cache.animation) {
var editingNode = cc.engine.getInstanceById(AnimUtils.Cache.rNode);
for (i = activeWidgets.length - 1; i >= 0; i--) {
widget = activeWidgets[i];
var node = widget.node;
if (widget.alignMode !== AlignMode.ALWAYS &&
animationState.animatedSinceLastFrame &&
node.isChildOf(editingNode)
) {
// widget contains in activeWidgets should aligned at least once
widget.enabled = false;
}
else {
align(node, widget);
if (editingNode) {
for (i = activeWidgets.length - 1; i >= 0; i--) {
widget = activeWidgets[i];
var node = widget.node;
if (widget.alignMode !== AlignMode.ALWAYS &&
animationState.animatedSinceLastFrame &&
node.isChildOf(editingNode)
) {
// widget contains in activeWidgets should aligned at least once
widget.enabled = false;
}
else {
align(node, widget);
}
}
}
}