Unity3D 零碎知识点集合 (持续更新)

1、拆分字符串
string strReceiveUDP = "0.1,0.2,0.3";
string[] arr = strReceiveUDP.Split(","[0]);
arr[0] = "0.1";
arr[1] = "0.2";

arr[2] = "0.3";


2、字符串转浮点型 string to float 
string str = "0.2";
float xx = float.Parse(str);


3、字符串与整型互转
e.gameObject.name=num.ToString();
num=int.Parse(e.gameObject.name);


4、获得ui的宽高 unity ugui

宽:gameObject.GetComponent().rect.width
高:gameObject.GetComponent().rect.height

你可能感兴趣的:(Unity3D)