Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

浅克隆对象的属性时,若该属性对应的是引用资产类型,应该自动增加引用计数。 #2403

Open
cptbtptpbcptdtptp opened this issue Oct 23, 2024 · 0 comments
Assignees
Labels
help wanted Extra attention is needed low priority Low priority issue

Comments

@cptbtptpbcptdtptp
Copy link
Collaborator

cptbtptpbcptdtptp commented Oct 23, 2024

可以看到引擎中很多地方其实为了处理这套逻辑在 cloneTo 里加了很多兜底代码。
比如:

// Renderer._cloneTo
  _cloneTo(target: Renderer, srcRoot: Entity, targetRoot: Entity): void {
    const materials = this._materials;
    for (let i = 0, n = materials.length; i < n; i++) {
      target._setMaterial(i, materials[i]);
    }
  }
// MeshRenderer._cloneTo
  override _cloneTo(target: MeshRenderer, srcRoot: Entity, targetRoot: Entity): void {
    super._cloneTo(target, srcRoot, targetRoot);
    target.mesh = this._mesh;
  }

// 其他如 SpriteRenderer,TextRenderer 中的逻辑就不枚举了

在执行的时候,反而执行了更多的逻辑。

@cptbtptpbcptdtptp cptbtptpbcptdtptp added help wanted Extra attention is needed low priority Low priority issue labels Oct 23, 2024
@cptbtptpbcptdtptp cptbtptpbcptdtptp self-assigned this Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed low priority Low priority issue
Projects
None yet
Development

No branches or pull requests

1 participant