fix add CanvasComponent undo bug (#4260)

This commit is contained in:
JoneLau
2019-04-22 16:32:29 +08:00
committed by pandamicro
parent 9ed06c4198
commit 34f7d5fc73
2 changed files with 7 additions and 5 deletions
+6 -4
View File
@@ -185,7 +185,7 @@ export class UI {
}
}
public addScreen (comp) {
public addScreen (comp: CanvasComponent) {
this._screens.push(comp);
if (comp.camera) {
comp.camera.view.visibility = this._screens.length;
@@ -204,12 +204,14 @@ export class UI {
return null;
}
public removeScreen (comp) {
public removeScreen (comp: CanvasComponent) {
const idx = this._screens.indexOf(comp);
if (idx !== -1) {
this._screens.splice(idx, 1);
if (idx === -1) {
return;
}
this._screens.splice(idx, 1);
let camera: Camera | null;
for (let i = idx; i < this._screens.length;) {
camera = this._screens[i].camera;
+1 -1
View File
@@ -154,4 +154,4 @@ export function baseNodePolyfill (BaseNode) {
return this.name + ', path: ' + path;
});
}
}
}