該文章持續更新!ide
1 void OnTriggerStay(Collider other) { 2 if (other.gameObject == player) { 3 Vector3 relPlayerPos = player.transform.position - transform.position; 4 RaycastHit hit; 5 6 if (Physics.Raycast(transform.position, relPlayerPos, out hit)) { 7 if (hit.collider.gameObject == player) { 8 lastPlayerSighting.position = player.transform.position; 9 } 10 } 11 } 12 }
1 public List<string> assetBundleName; 2 private Dictionary<string, WWW> wwwDownloading = new Dictionary<string, WWW>(); 3 private int maxCount = 4; 4 5 // Update is called once per frame 6 void Update () { 7 8 // 遍歷並將符合條件的直接移除 9 foreach (var item in wwwDownloading) 10 { 11 if (item.Value.isDone) 12 { 13 item.Value.assetBundle.Unload(true); 14 item.Value.Dispose(); 15 wwwDownloading.Remove(item.Key); 16 } 17 } 18 19 // 遍歷並將符合條件的直接移除 20 foreach (string s in assetBundleName) 21 { 22 if (wwwDownloading.Count < maxCount) 23 { 24 Load(s); 25 assetBundleName.Remove(s); 26 } 27 } 28 } 29 30 void Load(string abName) 31 { 32 WWW www = WWW.LoadFromCacheOrDownload(abName, 0); 33 wwwDownloading.Add(abName, www); 34 }