コード例 #1
0
ファイル: UnGfxWrap.cs プロジェクト: atom-chen/shisanshui-1
    static int GetSafeComponent(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Transform), typeof(System.Type)))
            {
                UnityEngine.Transform arg0 = (UnityEngine.Transform)ToLua.ToObject(L, 1);
                System.Type           arg1 = (System.Type)ToLua.ToObject(L, 2);
                UnityEngine.Component o    = UnGfx.GetSafeComponent(arg0, arg1);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.GameObject), typeof(System.Type)))
            {
                UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.ToObject(L, 1);
                System.Type            arg1 = (System.Type)ToLua.ToObject(L, 2);
                UnityEngine.Component  o    = UnGfx.GetSafeComponent(arg0, arg1);
                ToLua.Push(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnGfx.GetSafeComponent"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
コード例 #2
0
    public static void AddCollider(GameObject obj)
    {
        MeshFilter[] filters = obj.GetComponentsInChildren <MeshFilter>() as MeshFilter[];

        for (int i = 0; i < filters.Length; i++)
        {
            MeshFilter filter = filters[i];
            Mesh       mesh   = filter.mesh;

            MeshCollider mc = UnGfx.GetSafeComponent <MeshCollider>(filter.gameObject);
            mc.sharedMesh = mesh;
        }
    }