浏览代码

adding a disposal check

rickfromwork 4 年之前
父节点
当前提交
cbce658c54
共有 1 个文件被更改,包括 6 次插入1 次删除
  1. 6 1
      gui/src/3D/controls/touchButton3D.ts

+ 6 - 1
gui/src/3D/controls/touchButton3D.ts

@@ -120,7 +120,12 @@ export class TouchButton3D extends Button3D {
                 }
 
                 // Debug line mesh
-                debugLineMesh.dispose();
+                if (debugLineMesh)
+                {
+                    // remove the previous line before drawing the new one
+                    debugLineMesh.dispose();
+                }
+                
                 debugLineMesh = Mesh.CreateLines("debug_line", [
                     _this._collisionMesh.getAbsolutePosition(),
                     indexMesh.getAbsolutePosition()