Kaynağa Gözat

Fix textSize null case

nockawa 9 yıl önce
ebeveyn
işleme
21f6b85767
1 değiştirilmiş dosya ile 10 ekleme ve 6 silme
  1. 10 6
      src/Canvas2d/babylon.text2d.ts

+ 10 - 6
src/Canvas2d/babylon.text2d.ts

@@ -178,13 +178,17 @@
         }
 
         public get textSize(): Size {
-            if (!this._textSize && this.owner) {
-                let newSize = this.fontTexture.measureText(this._text, this._tabulationSize);
-                if (!newSize.equals(this._textSize)) {
-                    this.onPrimitivePropertyDirty(Prim2DBase.sizeProperty.flagId);
-                    this._positioningDirty();
+            if (!this._textSize) {
+                if (this.owner) {
+                    let newSize = this.fontTexture.measureText(this._text, this._tabulationSize);
+                    if (!newSize.equals(this._textSize)) {
+                        this.onPrimitivePropertyDirty(Prim2DBase.sizeProperty.flagId);
+                        this._positioningDirty();
+                    }
+                    this._textSize = newSize;
+                } else {
+                    return Text2D.nullSize;
                 }
-                this._textSize = newSize;
             }
             
             return this._textSize;