(1)List轉(zhuǎn)換 string數(shù)組
List<string> a = new List<string>();
a.Add("4");
string[] _a = a.ToArray();
(2)判斷是否存在文件夾躺酒,沒有則創(chuàng)建
if (Directory.Exists(url) == false)
{
Directory.CreateDirectory(url);
}
(3)可以獲取到這個值在數(shù)組中對應的key
數(shù)組.ToList().IndexOf(值)
(4)查找物體并設置角度和位置和大小
GameObject.Find(“Camera”).transform.position = new Vector3(0, 0, 0);
GameObject.Find(“Camera”).transform.rotation=Quaternion.Euler(0, 0, 0);
GameObject.Find(image + “(Clone)”).transform.localScale = new Vector3(1.0f, 1.0f, 1.0f);
(5)獲取時間并設置格式和類型
System.DateTime.Now.ToString(“yyMMddHHmmss”);
(6)啟動一個協(xié)程 停止所有協(xié)程
StartCoroutine(name());
StopAllCoroutines();
(7)查找所有包含這個腳本并調(diào)用其中函數(shù)(很實用)
腳本name[] handlers = (腳本name[])FindObjectsOfType(typeof(腳本name));
foreach (腳本name h in handlers)
{
h.函數(shù)();
}
(8)循環(huán)啟動某個函數(shù)
Invoke(“ShowShare”, 0.2f);
(9)打開網(wǎng)址
Application.OpenURL(url);
(10)自動旋轉(zhuǎn)
this.transform.RotateAround(this.transform.position, Vector3.up, 0.25f);
(11)跳轉(zhuǎn)場景
using UnityEngine.SceneManagement;
SceneManager.LoadScene(“Main”);
(12)截取字符串
string sModelName = this.name.Substring(4);
.ToList().IndexOf(listname)