示例#1
0
        //public static T LoadObject<T>(string resPath) where T : Object
        //{
        //    if (Path.GetExtension(resPath) == "")
        //    {
        //        resPath += ".prefab";
        //    }

        //    bool blUnLoad = false;
        //    T t = DeviceFactory.Instance.LoadObject<T>(resPath, blUnLoad);
        //    return t;
        //}

        public static void LoadObjectByWWW(string resPath, ResLoadInfo.callback fn = null, object fnPara = null)
        {
            if (Path.GetExtension(resPath) == "")
            {
                resPath += ".prefab";
            }
            DeviceFactory.Instance.LoadObjectWWW(resPath, fn, fnPara);
        }
示例#2
0
//        public override T LoadObject<T>(string path, bool blUnLoad = false)
//        {
//            string resPath = ResPath + path;
//            string r = Directory.GetCurrentDirectory() + "/" + resPath;
//            if (System.IO.File.Exists(r))
//            {
//#if UNITY_EDITOR
//                return AssetDatabase.LoadAssetAtPath<T>(resPath);
//#else
//                 return (T)Resources.Load(parsePrefabPath(path));
//#endif

//            }
//            else
//            {
//                return (T)Resources.Load(parsePrefabPath(path));
//            }

//        }


        public override void LoadObjectWWW(string resPath, ResLoadInfo.callback fn = null, object fnPara = null)
        {
            string path = ResPath + resPath;
            string r    = Directory.GetCurrentDirectory() + "/" + path;

            if (System.IO.File.Exists(r))
            {
                #if UNITY_EDITOR
                ResLoadInfo rli = new ResLoadInfo();
                rli.goEditor = AssetDatabase.LoadAssetAtPath <Object>(path);
                rli.success  = true;
                fn(rli, fnPara);
#endif
                return;
            }
            else
            {
                // Debug.Log("LoadObjectWWW no file: " + resPath);
                ResLoadInfo rli = new ResLoadInfo();
                rli.goEditor = Resources.Load(parsePrefabPath(path));
                rli.success  = false;
                fn(rli, fnPara);
            }

            //string originalFullPath = "Assets/Resources_Bundle/" + resPath;
            //string parseCommonPath = "Assets/Resources_Bundle/" + parseCommonAsset(resPath);
            //string md5Str = HashUtils.MD5(parseCommonPath) + ".ab";
            //string assetResPath = Application.streamingAssetsPath + "/res/" + md5Str;

            //if (System.IO.File.Exists(assetResPath))
            //{
            //    string[] dps = mainfest.GetAllDependencies(md5Str);

            //    string[] resPaths = new string[dps.Length + 1];
            //    if (dps != null && dps.Length > 0)
            //    {
            //        for (int i = 0; i < dps.Length; i++)
            //        {
            //            resPaths[i] = ResPathWWW + dps[i];
            //        }
            //    }
            //    resPaths[resPaths.Length - 1] = ResPathWWW + md5Str;// assetResPath;
            //    ResLoadInfo res = new ResLoadInfo();
            //    res.start(Path.GetFileNameWithoutExtension(resPath), resPaths, fn, fnPara);
            //}
            //else
            //{
            //}
        }
示例#3
0
        public virtual void LoadObjectWWW(string resPath, ResLoadInfo.callback fn = null, object fnPara = null)
        {
            string originalFullPath = "Assets/Resources_Bundle/" + resPath;
            string parseCommonPath  = "Assets/Resources_Bundle/" + parseCommonAsset(resPath);
            string md5Str           = HashUtils.MD5(parseCommonPath) + ".ab";
            string assetResPath     = ResPath + md5Str;

            if (directoryResLoadInfo.ContainsKey(ResPathWWW + md5Str))
            {
                ResLoadInfo rli = directoryResLoadInfo[ResPathWWW + md5Str];
                if (rli.success)
                {
                    rli.currentPrefabName = Path.GetFileNameWithoutExtension(resPath);
                    fn(rli, fnPara);
                }
                else
                {
                    rli.append(Path.GetFileNameWithoutExtension(resPath), fn, fnPara);
                }
                return;
            }
            if (true)//System.IO.File.Exists(assetResPath)
            {
                // Log.Info("LoadObjectWWW :" + Path.GetFileNameWithoutExtension(resPath)+ " " + assetResPath);
                string[] dps = mainfest.GetAllDependencies(md5Str);

                string[] resPaths = new string[dps.Length + 1];
                if (dps != null && dps.Length > 0)
                {
                    for (int i = 0; i < dps.Length; i++)
                    {
                        resPaths[i] = ResPathWWW + dps[i];
                    }
                }
                resPaths[resPaths.Length - 1] = ResPathWWW + md5Str;// assetResPath;
                ResLoadInfo res = new ResLoadInfo();
                res.isCache = parseCommonAssetCache(resPath);
                directoryResLoadInfo.Add(ResPathWWW + md5Str, res);
                res.start(Path.GetFileNameWithoutExtension(resPath), resPaths, fn, fnPara, resPath);
            }
            else
            {
                //Log.Error("LoadObjectWWW: " + parseCommonPath + "  " + md5Str + " not find file!");
                ResLoadInfo res = new ResLoadInfo();
                fn(res, null);
            }
        }