예제 #1
0
    void Start()
    {
        //for (var i = 0; i < maxCubes; i++) {
        //  for (var j = 0; j < maxCubes; j++) {
        //    for (var k = 0; k < maxCubes; k++) {
        //      var cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
        //      cube.transform.position = new Vector3(i, j, k);
        //      objects.Add(cube);
        //    }
        //  }
        //}

        Lua = new LuaState();
        Lua.L_OpenLibs();
        _lib = new UnityLib(Lua);

        var status = Lua.L_DoFile(luaFile);

        if (status != ThreadStatus.LUA_OK)
        {
            throw new Exception(Lua.ToString(-1));
        }

        if (!Lua.IsTable(-1))
        {
            throw new Exception("Framework main's return value is not a table");
        }

        Lua.GetField(-1, "make");
        if (!Lua.IsFunction(-1))
        {
            throw new Exception("Method make not found!");
        }
        luaMain = Lua.L_Ref(LuaDef.LUA_REGISTRYINDEX);

        tables.Add(Lua.CallFunction(luaMain, new object[] { go1.GetTable(Lua), go2.GetTable(Lua) }));

        _scale1 = Vector3.one;
        _scale2 = Vector3.one;
    }