浏览代码

Merge pull request #2914 from tovarisch/patch-1

Method to use parent coordinates
David Catuhe 7 年之前
父节点
当前提交
ce61ac4917
共有 1 个文件被更改,包括 10 次插入1 次删除
  1. 10 1
      gui/src/controls/control.ts

+ 10 - 1
gui/src/controls/control.ts

@@ -442,6 +442,15 @@ module BABYLON.GUI {
             return this;
             return this;
         }
         }
 
 
+        public getParentLocalCoordinates(globalCoordinates: Vector2): Vector2 {
+            var result = Vector2.Zero();
+
+            result.x = globalCoordinates.x - this._cachedParentMeasure.left;
+            result.y = globalCoordinates.y - this._cachedParentMeasure.top;
+
+            return result;
+        }
+        
         public moveToVector3(position: Vector3, scene: Scene): void {
         public moveToVector3(position: Vector3, scene: Scene): void {
             if (!this._host || this._root !== this._host._rootContainer) {
             if (!this._host || this._root !== this._host._rootContainer) {
                 Tools.Error("Cannot move a control to a vector3 if the control is not at root level");
                 Tools.Error("Cannot move a control to a vector3 if the control is not at root level");
@@ -998,4 +1007,4 @@ module BABYLON.GUI {
             
             
         }
         }
     }    
     }    
-}
+}