Skip to content

Commit

Permalink
[Bug] 修复切换 clip 后场景未及时更新以及一些状态切换问题 (cocos#45)
Browse files Browse the repository at this point in the history
* 修复 clipMenu 对象被冻结

* 修复切换 clip 后没有正常更新场景效果

* 修复切换 clip 后选中属性轨道查询可能出错
  • Loading branch information
yanOO1497 committed Mar 29, 2022
1 parent 462150a commit 4f0e36a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 7 additions & 3 deletions app/builtin/animator/source/panel/share/animation-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,11 @@ class AnimationEditor {
*/
public async updateSelectProperty(dragProperty: { nodePath: string; prop: string; clipUuid: string; isCurveSupport: boolean; missing?: boolean }) {
const that = this.vm;
const dump = await IgetPropValueAtFrame(that.currentClip, dragProperty.nodePath, dragProperty.prop, that.currentFrame);
if (dragProperty.clipUuid !== this.vm.currentClip) {
// 当前选中属性轨道的信息不属于当前编辑的 clip 则不查询信息
return;
}
const dump = await IgetPropValueAtFrame(dragProperty.clipUuid, dragProperty.nodePath, dragProperty.prop, that.currentFrame);
if (!dump) {
return;
}
Expand Down Expand Up @@ -1665,7 +1669,7 @@ class AnimationEditor {
that.clipsMenu = [];
this.updateClips(null);
} else {
that.clipsMenu = Object.freeze(clipInfo.clipsMenu);
that.clipsMenu = clipInfo.clipsMenu;
if (that.currentClip !== clipInfo.defaultClip) {
// 不能直接拿新的默认 clip 替换,需要查询当前的 clip 在 clip 菜单中是否存在
const index = clipInfo.clipsMenu.findIndex((item: any) => {
Expand Down Expand Up @@ -1729,7 +1733,7 @@ class AnimationEditor {
that.compIndex = animationCtrl.nodesDump?.compIndex;
// selectedId 的监听函数里需要处理 nodeDump ,因为需要在 nodeDump 有值的情况下再更新
if (typeof that.compIndex === 'number') {
that.clipsMenu = Object.freeze(rootInfo.clipsMenu);
that.clipsMenu = rootInfo.clipsMenu;
const { defaultClip } = rootInfo;
if (!defaultClip && (!that.clipsMenu || that.clipsMenu.length === 0)) {
this.updateClips(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -611,16 +611,18 @@ class AnimationManager extends EventEmitter implements ISceneEvents {
this._lastSaveClipDump = this.dumpClip(this._curEditRootNodeUuid, clipUuid);
try {
state.initialize(animData.node!);
state.setTime(0);
state.sample();
} catch (e) {
console.error(e);
}
state.setTime(0);
messageManager.broadcast('scene:animation-time-change', 0);

// 注册结束事件
this._registerAnimStateEvents(state);

this._curEditTime = 0;
cce.Engine.repaintInEditMode();
}

this.emit('scene:animation-clip-change', this._curEditRootNodeUuid, this._curEditClipUuid);
Expand Down

0 comments on commit 4f0e36a

Please sign in to comment.