예제 #1
0
    static int LoadAsset(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 3 && TypeChecker.CheckTypes <UnityEngine.GameObject, LuaInterface.LuaFunction>(L, 2))
            {
                string arg0 = ToLua.CheckString(L, 1);
                UnityEngine.GameObject arg1 = (UnityEngine.GameObject)ToLua.ToObject(L, 2);
                LuaFunction            arg2 = ToLua.ToLuaFunction(L, 3);
                ResourceLoad.LoadAsset(arg0, arg1, arg2);
                return(0);
            }
            else if (count == 3 && TypeChecker.CheckTypes <UnityEngine.Transform, LuaInterface.LuaFunction>(L, 2))
            {
                string arg0 = ToLua.CheckString(L, 1);
                UnityEngine.Transform arg1 = (UnityEngine.Transform)ToLua.ToObject(L, 2);
                LuaFunction           arg2 = ToLua.ToLuaFunction(L, 3);
                ResourceLoad.LoadAsset(arg0, arg1, arg2);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: ResourceLoad.LoadAsset"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
예제 #2
0
        public static ConfigFile LoadSingleConfigure(string filename)
        {
            ConfigFile file = null;

            float     delta  = Time.realtimeSinceStartup;
            TextAsset config = ResourceLoad.LoadAsset <TextAsset>("Config/" + filename);

            delta     = Time.realtimeSinceStartup - delta;
            readTime += delta;
            if (config != null)
            {
                file = LoadSingleConfigure(filename, config.text);
            }

            return(file);
        }
예제 #3
0
        public void LoadForResourceByUrl(string url, Action <UnityEngine.Object> callback)
        {
            var info = cfg.ResData.GetResInfoByUrl(url);

            if (info == null)
            {
                Debug.LogError("资源路径不存在 url:" + url);
                if (callback != null)
                {
                    callback(null);
                }
            }
            else
            {
                Object asset;
                if (mAllRes.ContainsKey(info.address))
                {
                    asset = mAllRes[info.address];
                }
                else
                {
                    asset = ResourceLoad.LoadAsset(url.Replace("r://", "").Replace(info.type, ""));
                    if (asset == null)
                    {
                        Debug.LogError("加载Resource资源失败 url:" + url);
                    }
                    else
                    {
                        mAllRes[info.address] = asset;
                    }
                }

                if (callback != null)
                {
                    callback(asset);
                }
            }
        }