浏览代码

Make sure terrain is not attached to main scene while rendering UV scene, prevents issues with interactives on main scene

trethaller 6 年之前
父节点
当前提交
f2da2e4a17
共有 1 个文件被更改,包括 10 次插入3 次删除
  1. 10 3
      hide/prefab/terrain/TerrainEditor.hx

+ 10 - 3
hide/prefab/terrain/TerrainEditor.hx

@@ -198,8 +198,12 @@ class TerrainEditor {
 			uvTex.depthBuffer = new h3d.mat.DepthBuffer(uvTex.width, uvTex.height);
 		}
 
-		@:privateAccess customScene.children = [];
-		@:privateAccess customScene.children.push(terrainPrefab.terrain); // Prevent OnRemove() call
+		var prevParent = terrainPrefab.terrain.parent;
+		@:privateAccess {
+			customScene.children = [terrainPrefab.terrain]; // Prevent OnRemove() call
+			terrainPrefab.terrain.parent = customScene;
+		}
+
 		customScene.camera = mainScene.camera;
 		brushPreview.reset();
 
@@ -230,7 +234,10 @@ class TerrainEditor {
 		for( tile in tiles )
 			tile.material.removePass(tile.material.getPass("terrainUV"));
 
-		mainScene.addChild(terrainPrefab.terrain);
+		@:privateAccess {
+			customScene.children = [];
+			terrainPrefab.terrain.parent = prevParent;
+		}
 		customScene.camera = null;
 
 		uvTexPixels = uvTex.capturePixels();