Ejemplo n.º 1
0
        void LoadLuaResources(string assetsPath)
        {
            try
            {
                if (beZip)
                {
                    string filePath = string.Format("{0}/{1}", Global_Tools.GetResourcesPath(), AL.MD5.ComputeString("textasset.bytes"));
                    byte[] data     = File.ReadAllBytes(filePath);
                    UnityEngine.AssetBundle bundle = UnityEngine.AssetBundle.LoadFromMemory(AL.Crypto.Decode(data));
                    foreach (UnityEngine.TextAsset lua in bundle.LoadAllAssets())
                    {
                        m_Resources.Add(lua.name, System.Text.Encoding.UTF8.GetString(lua.bytes));
                    }
                }
                else
                {
                    string        path    = UnityEngine.Application.dataPath + "/LuaScript";
                    DirectoryInfo dirInfo = new DirectoryInfo(path);
                    foreach (var lua in dirInfo.GetFiles("*.lua", SearchOption.AllDirectories))
                    {
                        string assetPath = lua.FullName.Substring(lua.FullName.IndexOf("LuaScript") + 10).Replace('\\', '/');
                        string name      = assetPath.Replace('/', '_');
                        m_Resources.Add(name, File.ReadAllText(lua.FullName));
                    }
                }
            }
            catch (Exception ex)
            {
#if !NETFX_CORE
                Console.WriteLine("Error initializing UnityScriptLoader : {0}", ex);
#endif
            }
        }
Ejemplo n.º 2
0
        static int _m_LoadAllAssets(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                UnityEngine.AssetBundle gen_to_be_invoked = (UnityEngine.AssetBundle)translator.FastGetCSObj(L, 1);


                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count == 1)
                {
                    UnityEngine.Object[] gen_ret = gen_to_be_invoked.LoadAllAssets(  );
                    translator.Push(L, gen_ret);



                    return(1);
                }
                if (gen_param_count == 2 && translator.Assignable <System.Type>(L, 2))
                {
                    System.Type _type = (System.Type)translator.GetObject(L, 2, typeof(System.Type));

                    UnityEngine.Object[] gen_ret = gen_to_be_invoked.LoadAllAssets(
                        _type);
                    translator.Push(L, gen_ret);



                    return(1);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.AssetBundle.LoadAllAssets!"));
        }
Ejemplo n.º 3
0
        static StackObject *LoadAllAssets_5(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 1);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            UnityEngine.AssetBundle instance_of_this_method = (UnityEngine.AssetBundle) typeof(UnityEngine.AssetBundle).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack), (CLR.Utils.Extensions.TypeFlags) 0);
            __intp.Free(ptr_of_this_method);

            var result_of_this_method = instance_of_this_method.LoadAllAssets();

            return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method));
        }
Ejemplo n.º 4
0
        public static Dictionary <string, UnityEngine.Object> LoadBundle(string assetBundleName)
        {
            assetBundleName = assetBundleName.ToLower();

            Dictionary <string, UnityEngine.Object> objects = new Dictionary <string, UnityEngine.Object>();

            if (!Define.IsAsync)
            {
                if (Define.IsEditor)
                {
                    string[] realPath = null;
                    realPath = Define.GetAssetPathsFromAssetBundle(assetBundleName);
                    foreach (string s in realPath)
                    {
                        //string assetName = Path.GetFileNameWithoutExtension(s);
                        UnityEngine.Object resource = Define.LoadAssetAtPath(s);
                        objects.Add(resource.name, resource);
                    }
                }
                return(objects);
            }

            string p = Path.Combine(PathHelper.AppHotfixResPath, assetBundleName);

            UnityEngine.AssetBundle assetBundle = null;
            if (File.Exists(p))
            {
                assetBundle = UnityEngine.AssetBundle.LoadFromFile(p);
            }
            else
            {
                p           = Path.Combine(PathHelper.AppResPath, assetBundleName);
                assetBundle = UnityEngine.AssetBundle.LoadFromFile(p);
            }

            if (assetBundle == null)
            {
                // 获取资源的时候会抛异常,这个地方不直接抛异常,因为有些地方需要Load之后判断是否Load成功
                UnityEngine.Debug.LogWarning($"assets bundle not found: {assetBundleName}");
                return(objects);
            }

            UnityEngine.Object[] assets = assetBundle.LoadAllAssets();
            foreach (UnityEngine.Object asset in assets)
            {
                objects.Add(asset.name, asset);
            }
            return(objects);
        }
Ejemplo n.º 5
0
 /** ロード。すべて。指定型のみ。
  *
  *      a_assetbundle		: アセットバンドル。
  *
  */
 public static System.Collections.Generic.List <T> LoadAll <T>(UnityEngine.AssetBundle a_assetbundle)
     where T : UnityEngine.Object
 {
     System.Collections.Generic.List <T> t_list = new System.Collections.Generic.List <T>();
     UnityEngine.Object[] t_object_list         = a_assetbundle.LoadAllAssets();
     if (t_object_list != null)
     {
         for (int ii = 0; ii < t_object_list.Length; ii++)
         {
             T t_load_asset = t_object_list[ii] as T;
             if (t_load_asset != null)
             {
                 t_list.Add(t_load_asset);
             }
         }
     }
     return(t_list);
 }
Ejemplo n.º 6
0
 /** ロード。すべて。
  *
  *      a_assetbundle		: アセットバンドル。
  *
  */
 public static UnityEngine.Object[] LoadAll(UnityEngine.AssetBundle a_assetbundle)
 {
     return(a_assetbundle.LoadAllAssets());
 }