Royi Bernthal 7 年 前
コミット
048485df98
2 ファイル変更9 行追加5 行削除
  1. 2 2
      gui/src/controls/multiLine.ts
  2. 7 3
      gui/src/segment.ts

+ 2 - 2
gui/src/controls/multiLine.ts

@@ -49,7 +49,7 @@ module BABYLON.GUI {
             this._markAsDirty();
         }
 
-        add(...items: (AbstractMesh | Control | ValueAndUnitVector2)[]): void {
+        add(...items: (AbstractMesh | Control | IValueAndUnitVector2)[]): void {
             items.forEach(item => {
                 var segment: Segment = this.push();
 
@@ -59,7 +59,7 @@ module BABYLON.GUI {
                 else if (item instanceof Control) {
                     segment.control = item;
                 }
-                else if (item instanceof ValueAndUnitVector2) {
+                else if (item.x != null && item.y != null) {
                     segment.x = item.x;
                     segment.y = item.y;
                 }

+ 7 - 3
gui/src/segment.ts

@@ -113,8 +113,12 @@ module BABYLON.GUI {
                 return new Vector2(this._control.centerX, this._control.centerY);
             }
             else {
-                //TODO: extract number from px and % - eventually in order to support %
-                return new Vector2(this.x as number, this.y as number); //temp - as number
+                var host: any = this._multiLine._host as any;
+
+                var xValue: number = this._x.getValueInPixel(host, Number(host._canvas.width));
+                var yValue: number = this._y.getValueInPixel(host, Number(host._canvas.height));
+                
+                return new Vector2(xValue, yValue);
             }
         }
 
@@ -125,7 +129,7 @@ module BABYLON.GUI {
 
     }
 
-    export class ValueAndUnitVector2 {
+    export interface IValueAndUnitVector2 {
 
         x: string | number;
         y: string | number;