该项目的目的是同时测试和演示来自 Unity DOTS 技术堆栈的多个新包。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

109 行
3.1 KiB

using System.Collections;
using System.Collections.Generic;
using Unity.Collections;
using Unity.Entities;
using UnityEngine;
public static class UITextExtensionMethods
{
static char[] buf = new char[1024];
public static void Format<T0>(this UnityEngine.UI.Text me, string format, T0 arg0)
{
int l = StringFormatter.Write(ref buf, 0, format, arg0);
me.Set(buf, l);
}
public static void Format<T0>(this TMPro.TextMeshProUGUI me, string format, T0 arg0)
{
int l = StringFormatter.Write(ref buf, 0, format, arg0);
me.Set(buf, l);
}
public static void Format<T0, T1>(this UnityEngine.UI.Text me, string format, T0 arg0, T1 arg1)
{
int l = StringFormatter.Write(ref buf, 0, format, arg0, arg1);
me.Set(buf, l);
}
public static void Format<T0, T1>(this TMPro.TextMeshProUGUI me, string format, T0 arg0, T1 arg1)
{
int l = StringFormatter.Write(ref buf, 0, format, arg0, arg1);
me.Set(buf, l);
}
public static void Format<T0, T1, T2>(this UnityEngine.UI.Text me, string format, T0 arg0, T1 arg1, T2 arg2)
{
int l = StringFormatter.Write(ref buf, 0, format, arg0, arg1, arg2);
me.Set(buf, l);
}
public static void Format<T0, T1, T2>(this TMPro.TextMeshProUGUI me, string format, T0 arg0, T1 arg1, T2 arg2)
{
int l = StringFormatter.Write(ref buf, 0, format, arg0, arg1, arg2);
me.Set(buf, l);
}
public static void Set(this UnityEngine.UI.Text me, char[] text, int length)
{
var old = me.text;
if (old.Length == length)
{
bool diff = false;
for (var i = 0; i < length; i++)
{
if (text[i] != old[i])
{
diff = true;
break;
}
}
if (!diff)
return;
}
me.text = new string(text, 0, length);
}
public static void Set(this UnityEngine.UI.Text me, ref NativeString64 text)
{
var originalText = new NativeString64(me.text);
if (originalText.CompareTo(text) == 0)
return;
me.text = text.ToString();
}
public static void Set(this TMPro.TextMeshProUGUI me, char[] text, int length)
{
var old = me.text;
if (old.Length == length)
{
bool diff = false;
for (var i = 0; i < length; i++)
{
if (text[i] != old[i])
{
diff = true;
break;
}
}
if (!diff)
return;
}
me.text = new string(text, 0, length);
}
public static void Set(this TMPro.TextMeshProUGUI me, ref NativeString64 text)
{
var originalText = new NativeString64(me.text);
if (originalText.CompareTo(text) == 0)
return;
me.text = text.ToString();
}
public static void SetRGB(this UnityEngine.UI.Graphic graphic, Color color)
{
var c = graphic.color;
graphic.color = new Color(color.r, color.g, color.b, c.a);
}
}