1.get set
private string name;
public string Name
{
get {
return name; }
set {
name = value; }
}
2、
IEnumerator Wait(float showTime, System.Action act)
{
yield return new WaitForSeconds(showTime);
if (act != null)
{
act();
}
}
StartCoroutine(Wait(showTime, () =>
{
this[id].Show(false);
}));
3、Resources.LoadAll()
Material[] materials;
materials = Resources.LoadAll<Material>("FlowMats");
4、鼠标操作:
4.1 鼠标点击
Input.GetMouseButtonDown(0); // 0(左键 ) / 1(右键)
4.2 鼠标拖拽
//按住鼠标左键上下左右移动时,使相机跟随
float x = Input.GetAxis(“Mouse X”); // 获取鼠标X轴变量
float y = Input.GetAxis(“Mouse Y”); // 获取鼠标Y轴变量
4.3 鼠标滚轮滑动
Input.GetAxis(“Mouse ScrollWheel”);
5、数据类型转换
5.1 string转float
string s = “123.2”;
//方法1
float f1 = Convert.ToSingle(s);
//方法2
float f2;
if (!float.TryParse(s, out f2))
{
Console.WriteLine("无法转换!");
}
5.2 string转int