Dispose() public method

public Dispose ( ) : void
return void
コード例 #1
0
ファイル: TestInt64.cs プロジェクト: zlanr/tolua
	void Start () 
    {
		#if UNITY_5		
		Application.logMessageReceived += ShowTips;
		#else
		Application.RegisterLogCallback(ShowTips);           
		#endif
		new LuaResLoader();
        LuaState lua = new LuaState();
        lua.Start();
        lua.DoString(script);				                   

        LuaFunction func = lua.GetFunction("TestInt64");
        func.BeginPCall();
		func.PushInt64(9223372036854775807 - 789);
        func.PCall();
        LuaInteger64 n64 = func.CheckInteger64();
        Debugger.Log("int64 return from lua is: {0}", n64);
        func.EndPCall();
        func.Dispose();
        func = null;

        lua.CheckTop();    
		lua.Dispose();  
		lua = null;
	}	
コード例 #2
0
	void Start () 
    {
        LuaState state = new LuaState();
        state.Start();
        LuaBinder.Bind(state);

        state.DoString(script);
        state["space"] = Space.World;

        LuaFunction func = state.GetFunction("TestEnum");
        func.BeginPCall();
        func.Push(Space.World);
        func.PCall();
        func.EndPCall();
        func.Dispose();
        func = null;

        GameObject go = GameObject.Find("/Light");
        Light light = go.GetComponent<Light>();
        func = state.GetFunction("ChangeLightType");
        func.BeginPCall();
        func.Push(light);
        func.Push(LightType.Directional);
        func.PCall();
        func.EndPCall();
        func.Dispose();
        func = null;
 
        state.CheckTop();
        state.Dispose();
        state = null;
	}
コード例 #3
0
    void Start()
    {
        LuaState lua = new LuaState();
        lua.Start();
        lua.DoString(script);

        string[] strs = { "aaa", "bbb", "ccc" };
        LuaFunction func = lua.GetFunction("TestArray");

        func.BeginPCall();
        func.Push(strs);
        func.PCall();
        double arg1 = func.CheckNumber();
        string arg2 = func.CheckString();
        bool arg3 = func.CheckBoolean();
        Debugger.Log("return is {0} {1} {2}", arg1, arg2, arg3);
        func.EndPCall();

        //转换一下类型,避免可变参数拆成多个参数传递
        object[] objs = func.Call((object)strs);

        if (objs != null)
        {
            Debugger.Log("return is {0} {1} {2}", objs[0], objs[1], objs[2]);
        }

        lua.CheckTop();
        func.Dispose();
        lua.Dispose();
    }
コード例 #4
0
ファイル: TestProtoBuffer.cs プロジェクト: tkial/tolua
    //实际应用如Socket.Send(LuaStringBuffer buffer)函数发送协议, 在lua中调用Socket.Send(pb_data)
    //读取协议 Socket.PeekMsgPacket() {return MsgPacket}; lua 中,取协议字节流 MsgPack.data 为 LuaStringBuffer类型
    //msg = Socket.PeekMsgPacket() 
    //pb_data = msg.data    
    void Start()
    {
#if UNITY_5		
		Application.logMessageReceived += ShowTips;
#else
        Application.RegisterLogCallback(ShowTips);
#endif  
        new LuaResLoader();        
        LuaState state = new LuaState();
        state.Start();
        Bind(state);
        state.OpenLibs(LuaDLL.luaopen_pb);                   

        state.DoString(script);
        LuaFunction func = state.GetFunction("Encoder");
        func.Call();
        func.Dispose();
        func = null;

        func = state.GetFunction("Decoder");
        func.Call();
        func.Dispose();
        func = null;

        state.CheckTop();
        state.Dispose();
        state = null;
    }
コード例 #5
0
ファイル: TestABLoader.cs プロジェクト: youxibuhaowana/01ulua
    void OnBundleLoad()
    {
        LuaState state = new LuaState();
        state.Start();

        state.DoString("print('hello world')");

        state.Dispose();
        state = null;
    }
コード例 #6
0
    void Awake()
    {
        LuaState lua = new LuaState();
        lua.Start();
        string hello = @"print('hello tolua#')";

        lua.DoString(hello, "HelloWorld.cs");
        lua.CheckTop();
        lua.Dispose();
        lua = null;
    }
コード例 #7
0
ファイル: HelloWorld.cs プロジェクト: benbon/tolua
	void Start () 
    {        
        LuaState lua = new LuaState();
        string hello =
            @"                
                print('hello tolua, 广告招租')                
            ";

        lua.DoString(hello, "hello");
        lua.CheckTop();
        lua.Dispose();
	}
コード例 #8
0
ファイル: ScriptsFromFile.cs プロジェクト: benbon/tolua
	void Start () 
    {        
        LuaState lua = new LuaState();
        lua.Start();        
        
        string fullPath = Application.dataPath + "/ToLua/Examples/02_ScriptsFromFile";
        lua.AddSearchPath(fullPath);         
        lua.DoFile("ScriptsFromFile.lua");        
        //lua.DoString("require 'ScriptsFromFile'");                             
        //lua.Require("ScriptsFromFile");                

        lua.Dispose();
	}
コード例 #9
0
ファイル: TestCustomLoader.cs プロジェクト: benbon/tolua
	void Start () 
    {        
        Application.RegisterLogCallback(Logger);
        new LuaResLoader();        
        LuaState state = new LuaState();
        state.Start();

        state.DoFile("TestLoader.lua");

        LuaFunction func = state.GetFunction("Test");        
        func.Call();
        Application.RegisterLogCallback(null);
        func.Dispose();
        state.Dispose();
	}
コード例 #10
0
ファイル: AccessingLuaVariables.cs プロジェクト: benbon/tolua
	void Start () 
    {        
        LuaState lua = new LuaState();
        lua["Objs2Spawn"] = 5;
        lua.DoString(script);

        Debugger.Log("Read var from lua: {0}", lua["var2read"]);
        Debugger.Log("Read table var from lua: {0}", lua["Layers.default"]);

        LuaFunction func = lua["TestFunc"] as LuaFunction;
        func.Call();

        func.Dispose();
        lua.CheckTop();
        lua.Dispose();
	}
コード例 #11
0
    void Start()
    {
        LuaState lua = new LuaState();
        lua.Start();
        lua["Objs2Spawn"] = 5;
        lua.DoString(script);

        //通过LuaState访问
        Debugger.Log("Read var from lua: {0}", lua["var2read"]);
        Debugger.Log("Read table var from lua: {0}", lua["varTable.default"]);

        LuaFunction func = lua["TestFunc"] as LuaFunction;
        func.Call();
        func.Dispose();

        //cache成LuaTable进行访问
        LuaTable table = lua.GetTable("varTable");
        Debugger.Log("Read varTable from lua, default: {0} name: {1}", table["default"], table["map.name"]);
        table["map.name"] = "new";
        Debugger.Log("Modify varTable name: {0}", table["map.name"]);

        table.AddTable("newmap");
        LuaTable table1 = (LuaTable)table["newmap"];
        table1["name"] = "table1";
        Debugger.Log("varTable.newmap name: {0}", table1["name"]);
        table1.Dispose();

        table1 = table.GetMetaTable();

        if (table1 != null)
        {
            Debugger.Log("varTable metatable name: {0}", table1["name"]);
        }

        object[] list = table.ToArray();

        for (int i = 0; i < list.Length; i++)
        {
            Debugger.Log("varTable[{0}], is {1}", i, list[i]);
        }

        table.Dispose();
        lua.CheckTop();
        lua.Dispose();
    }
コード例 #12
0
ファイル: TestCustomLoader.cs プロジェクト: tkial/tolua
	void Start () 
    {
#if UNITY_5
        Application.logMessageReceived += Logger;
#else
        Application.RegisterLogCallback(Logger);
#endif    
        new LuaResLoader();        
        LuaState state = new LuaState();
        state.Start();

        state.DoFile("TestLoader.lua");

        LuaFunction func = state.GetFunction("Test");        
        func.Call();        
        func.Dispose();
        state.Dispose();
#if UNITY_5
        Application.logMessageReceived -= Logger;
#else
        Application.RegisterLogCallback(null);
#endif    
	}
コード例 #13
0
    void Awake()
    {
        map.Add(1, new TestAccount(2, "水水", 0));
        map.Add(2, new TestAccount(1, "王伟", 1));
        map.Add(3, new TestAccount(2, "王芳", 0));

        LuaState luaState = new LuaState();
        luaState.Start();
        BindMap(luaState);

        luaState.DoString(script);
        LuaFunction func = luaState.GetFunction("TestDict");
        func.BeginPCall();
        func.Push(map);
        func.PCall();
        func.EndPCall();

        func.Dispose();
        func = null;
        luaState.CheckTop();
        luaState.Dispose();
        luaState = null;
    }
コード例 #14
0
ファイル: TestProtoBuffer.cs プロジェクト: benbon/tolua
    //实际应用如Socket.Send(LuaStringBuffer buffer)函数发送协议, 在lua中调用Socket.Send(pb_data)
    //读取协议 Socket.PeekMsgPacket() {return MsgPacket}; lua 中,取协议字节流 MsgPack.data 为 LuaStringBuffer类型
    //msg = Socket.PeekMsgPacket() 
    //pb_data = msg.data    
    void Start()
    {
        Application.RegisterLogCallback(ShowTips);  
        new LuaResLoader();        
        LuaState state = new LuaState();
        state.Start();
        Bind(state);
        state.OpenLibs(LuaDLL.luaopen_pb);                   

        state.DoString(script);
        LuaFunction func = state.GetFunction("Encoder");
        func.Call();
        func.Dispose();
        func = null;

        func = state.GetFunction("Decoder");
        func.Call();
        func.Dispose();
        func = null;

        state.CheckTop();
        state.Dispose();
        state = null;
    }
コード例 #15
0
ファイル: TestInt64.cs プロジェクト: benbon/tolua
	void Start () 
    {
        LuaState lua = new LuaState();
        lua.Start();
        lua.DoString(script);

        long x  = 123456789123456789;
        double low = (double)(x & 0xFFFFFFFF);
        double high = (double)(x >> 32);
        Debugger.Log("number x low is {0}, high is {1}", low, high);

        LuaFunction func = lua.GetFunction("TestInt64");
        func.BeginPCall();
        func.PushInt64(123456789123456000);
        func.PCall();
        LuaInteger64 n64 = func.CheckInteger64();
        Debugger.Log("int64 return from lua is: {0}", n64);
        func.EndPCall();
        func.Dispose();
        func = null;

        lua.CheckTop();
        lua.Dispose();        
	}	
コード例 #16
0
ファイル: TestInherit.cs プロジェクト: woshihuo12/UnityHello
    void Start()
    {
        lua = new LuaState();
        lua.Start();
        LuaBinder.Bind(lua);
        lua.DoString(script, "TestInherit.cs");

        float time = Time.realtimeSinceStartup;

        for (int i = 0; i < 200000; i++)
        {
            Vector3 v = transform.position;
            transform.position = v;
        }

        time = Time.realtimeSinceStartup - time;
        Debugger.Log("c# Transform get set cost time: " + time);

        LuaFunction func = lua.GetFunction("Test");
        func.BeginPCall();
        func.Push(transform);
        func.PCall();
        func.EndPCall();

        lua.CheckTop();
        lua.Dispose();
        lua = null;
    }
コード例 #17
0
 void OnBundleLoad()
 {
     LuaState state = new LuaState();
     state.Start();
     state.DoString("print('hello tolua#:'..tostring(Vector3.zero))");
     state.DoFile("Main.lua");
     LuaFunction func = state.GetFunction("Main");
     func.Call();
     func.Dispose();
     state.Dispose();
     state = null;
 }