浏览代码

Make text_blob in mesh_info nullable.

/main
Yuncong Zhang 5 年前
当前提交
84407c13
共有 2 个文件被更改,包括 16 次插入15 次删除
  1. 2
      Runtime/painting/text_painter.cs
  2. 29
      Runtime/ui/painting/txt/mesh_generator.cs

2
Runtime/painting/text_painter.cs


{
var rectNextLineTop = this._paragraph.getNextLineStartRectTop();
if (rectNextLineTop != null) {
return new Offset(0, (float) rectNextLineTop);
return new Offset(0, rectNextLineTop.Value);
}
}
}

29
Runtime/ui/painting/txt/mesh_generator.cs


static readonly Dictionary<MeshKey, MeshInfo> _meshes = new Dictionary<MeshKey, MeshInfo>();
static long _frameCount = 0;
public TextBlob textBlob;
public TextBlob? textBlob;
public float scale;
public uiMatrix3 matrix;

ObjectPool<uiMeshMesh>.release(this._mesh);
this._mesh = null;
this._resolved = false;
this.textBlob = null;
}
public static TextBlobMesh create(TextBlob textBlob, float scale, uiMatrix3 matrix) {

this._resolved = true;
var style = this.textBlob.style;
var style = this.textBlob.Value.style;
var text = this.textBlob.text;
var key = MeshKey.create(this.textBlob.instanceId, this.scale);
var text = this.textBlob.Value.text;
var key = MeshKey.create(this.textBlob.Value.instanceId, this.scale);
var fontInfo = FontManager.instance.getOrCreate(style.fontFamily, style.fontWeight, style.fontStyle);
var font = fontInfo.font;

}
// Handling Emoji
char startingChar = text[this.textBlob.textOffset];
char startingChar = text[this.textBlob.Value.textOffset];
if (char.IsHighSurrogate(startingChar) || EmojiUtils.isSingleCharEmoji(startingChar)) {
var vert = ObjectPool<uiList<Vector3>>.alloc();
var tri = ObjectPool<uiList<int>>.alloc();

var minY = minMaxRect.top;
var maxY = minMaxRect.bottom;
for (int i = 0; i < this.textBlob.textSize; i++) {
char a = text[this.textBlob.textOffset + i];
for (int i = 0; i < this.textBlob.Value.textSize; i++) {
char a = text[this.textBlob.Value.textOffset + i];
D.assert(i + 1 < this.textBlob.textSize);
D.assert(this.textBlob.textOffset + i + 1 < this.textBlob.text.Length);
char b = text[this.textBlob.textOffset + i + 1];
D.assert(i + 1 < this.textBlob.Value.textSize);
D.assert(this.textBlob.Value.textOffset + i + 1 < this.textBlob.Value.text.Length);
char b = text[this.textBlob.Value.textOffset + i + 1];
D.assert(char.IsLowSurrogate(b));
code = char.ConvertToUtf32(a, b);
}

var uvRect = EmojiUtils.getUVRect(code);
var positionX = this.textBlob.getPositionX(i);
var positionX = this.textBlob.Value.getPositionX(i);
int baseIndex = vert.Count;
vert.Add(new Vector3(positionX + minX, minY, 0));

return this._mesh;
}
var length = this.textBlob.textSize;
var length = this.textBlob.Value.textSize;
var fontSizeToLoad = Mathf.CeilToInt(style.UnityFontSize * this.scale);
var vertices = ObjectPool<uiList<Vector3>>.alloc();

uv.SetCapacity(length * 4);
for (int charIndex = 0; charIndex < length; ++charIndex) {
var ch = text[charIndex + this.textBlob.textOffset];
var ch = text[charIndex + this.textBlob.Value.textOffset];
var positionX = this.textBlob.getPositionX(charIndex);
var positionX = this.textBlob.Value.getPositionX(charIndex);
if (LayoutUtils.isWordSpace(ch) || LayoutUtils.isLineEndSpace(ch) || ch == '\t') {
continue;
}

正在加载...
取消
保存