コード例 #1
0
	// Use this for initialization
	void Start () {
        LuaState l = new LuaState();

        // First run the script so the function is created
        l.DoString(script);

        // Get the function object
        LuaFunction f = l.GetFunction("luaFunc");

        // Call it, takes a variable number of object parameters and attempts to interpet them appropriately
        object[] r = f.Call("I called a lua function!");

        // Lua functions can have variable returns, so we again store those as a C# object array, and in this case print the first one
        print(r[0]);
	}
コード例 #2
0
	// Use this for initialization
	void Start () {
        LuaState l = new LuaState();
        // Assign to global scope variables as if they're keys in a dictionary (they are really)
        l["Objs2Spawn"] = 5;
        l.DoString(script);

        // Read from the global scope the same way
        print("Read from lua: " + l["var2read"].ToString());

        // Get the lua table as LuaTable object
        LuaTable particles = (LuaTable)l["particles"];

        // Typical foreach over values in table
        foreach( ParticleSystem ps in particles.Values )
        {
            ps.Play();
        }
	}
コード例 #3
0
 // Use this for initialization
 void Start()
 {
     LuaState l = new LuaState();
     l.DoString(scriptFile.text);
 }
コード例 #4
0
ファイル: HelloWorld.cs プロジェクト: ZeroToken/MyTools
	// Use this for initialization
	void Start () {
        LuaState l = new LuaState();
        string str = "print('hello world 世界')";
        l.DoString(str);
	}
コード例 #5
0
	//反射调用
	void Start () {
        LuaState lua = new LuaState();
        lua.DoString(script);
	}