该文章持续更新!

  1. 协程的返回值必需是 IEnumerator
  2. 协程的参数不能加关键字 ref 或 out
  3. 在函数 Update 和 FixedUpdate 中不能使用 yield 语句,但可以启动协程
  4. yield return 语句不能位于 try-catch 语句块中,但可以位于 try-finally 中的 finally 语句块中
  5. yield return 语句不能放在匿名方法中
  6. yield return 语句不能放在 unsafe 语句块中
  7. UnityScript(即:Unity JavaScript的简称)中字符串的类型为String,而不是string
  8. UnityScript的布尔为boolean,而不是C#的bool
  9. UnityScript中的函数默认访问权限都是public,且所有的默认函数都为虚函数(virtual function),而且不需要加上virtual关键字
  10. 与C#脚本不同,在UnityScript中使用协程时,可以不使用StartCoroutine方法,而是像调用普通函数那样使用协程
  11. 在Unity中,参与 Lightmaps 烘焙的物体必须是静态对象
  12. 在Unity中,v5.x以前版本的 Light 的 GI Mode 在 v5.x 中变更为 Baking
  13. 射线探测物体参考代码:
     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 }
    射线探测物体参考代码

相关文章: