Fix the error when adapting the adaptation editor (#2524)

* fix: the error when adapting the adaptation editor
This commit is contained in:
AZhan
2025-01-21 16:44:51 +08:00
committed by GitHub
parent decdc46349
commit f8d508e7d0
3 changed files with 11 additions and 3 deletions

View File

@@ -283,7 +283,6 @@ export class Sprite extends ReferResource {
this._bounds = null;
this._atlas = null;
this._texture = null;
this._updateFlagManager = null;
}
private _calDefaultSize(): void {

View File

@@ -589,8 +589,8 @@ export class Entity extends EngineObject {
}
this._parent = null;
this._siblingIndex = -1;
this._dispatchModify(EntityModifyFlags.Child, oldParent);
}
this._dispatchModify(EntityModifyFlags.Child, oldParent);
}
/**
@@ -711,6 +711,10 @@ export class Entity extends EngineObject {
}
}
this._setParentChange();
} else {
if (parent && siblingIndex !== undefined) {
this.siblingIndex = siblingIndex;
}
}
}

View File

@@ -1,6 +1,6 @@
import { Entity, Script } from "@galacean/engine-core";
import { WebGLEngine } from "@galacean/engine-rhi-webgl";
import { vi, describe, beforeEach, expect, it } from "vitest";
import { beforeEach, describe, expect, it, vi } from "vitest";
class TestComponent extends Script {}
@@ -232,6 +232,11 @@ describe("Entity", async () => {
parent.addChild(child);
expect(child.parent).eq(parent);
expect(child.scene).eq(scene);
const childAno = new Entity(engine, "childAno");
childAno.parent = parent;
parent.addChild(0, childAno);
expect(childAno.siblingIndex).eq(0);
});
it("removeChild", () => {