Skip to content

Commit

Permalink
Restore the model when the UImeshRenderer is destroyed.
Browse files Browse the repository at this point in the history
  • Loading branch information
LinYunMo committed Aug 14, 2023
1 parent d007151 commit 2769cf8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
1 change: 0 additions & 1 deletion cocos/2d/components/graphics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ export class Graphics extends UIRenderer {
}

public onDestroy (): void {
this._sceneGetter = null;
if (JSB) {
this._graphicsNativeProxy.destroy();
this.model = null;
Expand Down
4 changes: 3 additions & 1 deletion cocos/2d/components/ui-mesh-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ export class UIMeshRenderer extends Component {
return;
}

this._modelComponent._sceneGetter = null;
if (this._modelComponent.enabledInHierarchy) {
this._modelComponent._attachToScene();
}
}

/**
Expand Down
5 changes: 4 additions & 1 deletion cocos/3d/framework/mesh-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,10 @@ export class MeshRenderer extends ModelRenderer {
}
}

protected _attachToScene (): void {
/**
* @engineInternal
*/
public _attachToScene (): void {
if (!this.node.scene || !this._model) {
return;
}
Expand Down
5 changes: 4 additions & 1 deletion cocos/misc/model-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ export class ModelRenderer extends Renderer {
this._updatePriority();
}

protected _attachToScene (): void {
/**
* @engineInternal
*/
public _attachToScene (): void {
}

/**
Expand Down

0 comments on commit 2769cf8

Please sign in to comment.