From 0250cd663bc01bf44c82a171e5ddc21151bdccba Mon Sep 17 00:00:00 2001 From: Myway Date: Fri, 21 Feb 2020 19:00:14 +0800 Subject: [PATCH] =?UTF-8?q?Terrain=20restore=E4=B8=8D=E5=86=8D=E5=A4=84?= =?UTF-8?q?=E7=90=86asset=20(#6203)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cocos/terrain/terrain.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos/terrain/terrain.ts b/cocos/terrain/terrain.ts index 9d4018bab1..7e123d1bae 100644 --- a/cocos/terrain/terrain.ts +++ b/cocos/terrain/terrain.ts @@ -896,7 +896,7 @@ export class Terrain extends Component { public onRestore () { this.onDisable(); this.onLoad(); - this._buildImp(); + this._buildImp(true); } public update (dtime: number) { @@ -1255,12 +1255,12 @@ export class Terrain extends Component { } } - private _buildImp () { + private _buildImp (restore: boolean = false) { if (this.valid) { return true; } - if (this.__asset != null) { + if (!restore && this.__asset != null) { this._tileSize = this.__asset.tileSize; this._blockCount = this.__asset.blockCount; this._weightMapSize = this.__asset.weightMapSize; @@ -1295,7 +1295,7 @@ export class Terrain extends Component { // build heights & normals const vcount = this.vertexCount[0] * this.vertexCount[1]; - if (this._heights.length !== vcount) { + if (this._heights === null || this._heights.length !== vcount) { this._heights = new Uint16Array(vcount); this._normals = new Array(vcount * 3);