Commit 5c2ffb34 authored by haiyoucuv's avatar haiyoucuv

更改

parent d41df591
...@@ -34,6 +34,11 @@ export class HTMLRichText extends Component { ...@@ -34,6 +34,11 @@ export class HTMLRichText extends Component {
protected start() { protected start() {
} }
imgAssets: ImageAsset = null;
t2d: Texture2D = new Texture2D();
sf: SpriteFrame = new SpriteFrame();
async setTxt(html: string) { async setTxt(html: string) {
if (!html) { if (!html) {
...@@ -66,15 +71,12 @@ export class HTMLRichText extends Component { ...@@ -66,15 +71,12 @@ export class HTMLRichText extends Component {
if (!canvas) return; if (!canvas) return;
// document.body.appendChild(canvas); this.imgAssets = new ImageAsset(canvas);
const t2d = new Texture2D();
t2d.image = new ImageAsset(canvas);
const sf = new SpriteFrame(); this.t2d.image = this.imgAssets;
sf.texture = t2d; this.sf.texture = this.t2d;
this.node.getComponent(Sprite).spriteFrame = sf; this.node.getComponent(Sprite).spriteFrame = this.sf;
this.node.getComponent(UITransform).setContentSize(canvas.width, canvas.height); this.node.getComponent(UITransform).setContentSize(canvas.width, canvas.height);
...@@ -82,6 +84,12 @@ export class HTMLRichText extends Component { ...@@ -82,6 +84,12 @@ export class HTMLRichText extends Component {
} }
onDestroy() {
this.imgAssets.destroy();
this.t2d.destroy();
this.sf.destroy();
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment