tolua#的Examples-06_LuaCoroutine2

关键代码

    string script =
    @"
        function CoExample()            
            WaitForSeconds(2)
            print('WaitForSeconds end time: '.. UnityEngine.Time.time)
            WaitForFixedUpdate()
            print('WaitForFixedUpdate end frameCount: '..UnityEngine.Time.frameCount)
            WaitForEndOfFrame()
            print('WaitForEndOfFrame end frameCount: '..UnityEngine.Time.frameCount)
            Yield(null)
            print('yield null end frameCount: '..UnityEngine.Time.frameCount)
            Yield(0)
            print('yield(0) end frameCime: '..UnityEngine.Time.frameCount)
            local www = UnityEngine.WWW('http://www.baidu.com')
            Yield(www)
            print('yield(www) end time: '.. UnityEngine.Time.time)
            local s = tolua.tolstring(www.bytes)
            print(s:sub(1, 128))
            print('coroutine over')
        end

        function TestCo()            
            StartCoroutine(CoExample)                                  
        end

        local coDelay = nil

        function Delay()
            local c = 1

            while true do
                WaitForSeconds(1)
                print('Count: '..c)
                c = c + 1
            end
        end

        function StartDelay()
            coDelay = StartCoroutine(Delay)            
        end

        function StopDelay()
            StopCoroutine(coDelay)
        end
    ";

这个实际上就是延续了上一个例子,每个功能再演示一次,具体自己看就可以了。

上一篇: tolua#的Examples-05_LuaCoroutine
下一篇: tolua#的Examples-07_LuaThread
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags:
相关日志:
评论: 0 | 引用: 0 | 查看次数: -
发表评论
昵 称:
密 码: 游客发言不需要密码.
邮 箱: 邮件地址支持Gravatar头像,邮箱地址不会公开.
网 址: 输入网址便于回访.
内 容:
验证码:
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 1000 字 | UBB代码 开启 | [img]标签 关闭