Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

参数为Vector3[]时候类型匹配不上 #67

Closed
tenvick opened this issue Sep 21, 2015 · 3 comments
Closed

参数为Vector3[]时候类型匹配不上 #67

tenvick opened this issue Sep 21, 2015 · 3 comments

Comments

@tenvick
Copy link

tenvick commented Sep 21, 2015

EG:C#
class Helper{
//重载方法中有 数组
public static void move(GameObject obj,Vector3[] paths,float t){}
//有重载方法
public static void move(GameObject obj,Vector pos,float t){}
}
上面的函数会调用不了
lua
local paths={}
table.insert(paths,Vector3(0.1,1,0))
table.insert(paths,Vector3(1.1,1,2.3))
Helper. move(go,paths,1)

报错 No matched override function to call

@yongkangchen
Copy link
Collaborator

slua暂时对数组的支持不全,你需要自行添加Vector3[]的支持到luaobject_overload.cs(或者你新建一个cs文件),实现方法参考static public bool checkType(IntPtr l, int p, out string[] t)如下:

        static public bool checkType(IntPtr l, int p, out Vector3[] t)
        {
            LuaDLL.luaL_checktype(l, p, LuaTypes.LUA_TTABLE);
            int n = LuaDLL.lua_rawlen(l, p);
            t = new Vector3[n];
            for (int k = 0; k < n; k++)
            {
                LuaDLL.lua_rawgeti(l, p, k + 1);
                checkType(l, -1, out t[k]);
                LuaDLL.lua_pop(l, 1);
            }
            return true;
        }

@pangweiwei
Copy link
Owner

你需要在LuaObject_overload.cs加入vector3[]的的checkType,

static public bool checkType(IntPtr l, int p, out Vector3[] array)
{
...
}

@yongkangchen
Copy link
Collaborator

所以问题是c#里数组作为参数,lua调用时重载无法匹配

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants