unity
unity延时方法Invoke和InvokeRepeating
{ "code": "using UnityEngine;\nusing System.Collections;\n\nclass TimeOutIntertval : MonoBehaviour {\n // 当前时间\n private float nowTime;\n // 执行重复方法的次数\n private int count;\n\n // Use this for initialization\n void Start () {\n nowTime = Time.time;\n Debug.Log(\"时间点:\" + nowTime);\n this.Invoke(\"setTimeOut\", 3.0f);\n this.InvokeRepeating(\"setInterval\", 2.0f, 1.0f);\n }\n\n private void setTimeOut() {\n nowTime = Time.time;\n Debug.Log(\"执行延时方法:\" + nowTime);\n }\n\n private void setInterval() {\n nowTime = Time.time;\n Debug.Log(\"执行重复方法:\" + nowTime);\n count += 1;\n if(count == 5) this.CancelInvoke();\n }\n}\n" }