Ulua_toLua_基本案例(六)_LuaCoroutine2

using UnityEngine;
using System.Collections;
using LuaInterface;

public class TestCoroutine2 : MonoBehaviour
{
    LuaState luaState = null;    

    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()
            print('TestCo')
            local co = coroutine.create(CoExample)

            local flag, msg = coroutine.resume(co)

            if not flag then
                error(msg)
            end
        end
    ";

	void Awake ()
    {
        luaState = new LuaState();
        luaState.Start();
        LuaBinder.Bind(luaState);
        LuaCoroutine.Register(luaState, this);

        luaState.DoString(script);
        LuaFunction func = luaState.GetFunction("TestCo");
        func.Call();
        func.Dispose();
	}

    void OnDestroy()
    {
        luaState.Dispose();
        luaState = null;
    }
}
时间: 2024-08-03 02:03:18

Ulua_toLua_基本案例(六)_LuaCoroutine2的相关文章

微信营销案例六 爱心漂流瓶

案例六:招商银行 爱心漂流瓶 微信官方对已漂流瓶的设置,也让很多商家看漂流瓶的商机,微信商家开始通过扔瓶子做活动推广.使得合作商家推广的活动在某一时间段内抛出的”漂流瓶”数量大增,普通用户”捞”到的频率也会增加.招商银行就是其中一个. 日前,招商银行发起了一个微信“爱心漂流瓶的活动”:微信用户用“漂流瓶”功能捡到招商银行漂流瓶,回复之后招商银行便会通过“小积分,微慈善”平台为自闭症儿童提供帮助.在此活动期间,有媒体统计,用户每捡十次漂流瓶便基本上有一次会捡到招行的爱心漂流瓶. 微信营销案例六 爱

WPF案例 (六) 动态切换UI布局

原文:WPF案例 (六) 动态切换UI布局 这个Wpf示例对同一个界面支持以ListView或者CardView的布局方式呈现界面,使用控件ItemsControl绑定数据源,使用DataTemplate为ItemsControl分别预定义了ListView和CardView的样式,在程序运行时,可在这两种Layout之间互相切换,界面如下.源代码在这里下载   为ItemsControl定义ListView UI布局的ItemTemplate,并指定MouseOver时DataTemplate

基于Netty5.0入门案例六之NettyServer群发消息

前言介绍: 我们的NettyServer收到数据后,需要群发给当前链接到服务端的所有小伙伴. 技术点: 1.ChannelGroup [io.netty.channel.group.DefaultChannelGroup] 欢迎加入:itstack | Netty The Sniper 5360692 环境需求: 1.jdk1.7以上[jdk1.7以下只能部分支持netty] 2.Netty-all-5.0[netty3.x 4.x 5每次的变化较大,接口类名也随着变化] 3.telnet 测试

JavaScript案例六:简单省市联动(NBA版)

JavaScript实现简单省市(NBA版)联动 <!DOCTYPE html> <html> <head> <title>JavaScript实现简单省市(NBA版)联动</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <script type="text/javascrip

Ulua_toLua_基本案例(八)_LuaAccessingArray

using UnityEngine; using LuaInterface; public class AccessingArray : MonoBehaviour { private string script = @" function TestArray(strs) local len = strs.Length for i = 0, len - 1 do print(strs[i]) end return 1, '123', true end "; void Start() {

案例六:实现1+2+3+...+100的求和计算

package project_06; /** * 2018年9月7日22:45:05 * @author Suaron XiaMen * */ public class Summation { //计算1+2+3+...+100 public static void main(String[] args) { int summation=0; for(int i=1;i<=100;i++){ summation+=i; } System.out.println("1+2+3+...+10

HTML前端--各种小案例

掬一捧清水,放逐在江河,融入流逝的岁月,将心洗净; 捻一缕心香,遥寄在云端,在最深的红尘里重逢,将心揉碎; 望一程山水,徘徊在月下,在相思渡口苦守寒冬,将心落寞. 案例一: 隐藏扩展域,并去掉after,并去掉高度 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> <sty

bash 脚本参数案例总结

bash 脚本参数案例总结 案例1.通过命令行参数给定两个数字,输出其中较大的数值: 方法1:如下 #!/bin/bash #Name: #Version: #Type: #Date: #Author #Email: if [ $# -lt 2 ];then echo "Two intergers." fi if [ $1 -ge $2 ];then echo "Max is $1" else echo "Max is $2" fi 方法2:如下

MapReduce算法形式六:只有Map独自作战

案例六:Map独自直接输出 之前一直没有用过这个map独自输出的模式,就算是输出一些简单的我也会经过一次reduce输出,但是,发现这个map输出的结果跟我预想的有点不一样,我一直以为shuffle的过程会在map结尾,reduce开头进行,会有合并的,可是shuffle只做了分区,排序,然后就直接罗列出来了,这算是涨姿势了,之前理解的合并,归约还是有点问题的,果然毛爷爷说的实践才能出真理~~(向毛爷爷致敬,敬礼) 码就很简单,没什么可解释的,但是结果就得好好捉摸一下了,看看之后能用在哪里,回头