Ejemplo n.º 1
0
        public string GetABUrl(string abName, bool isManifest = false)
        {
            if (!isManifest && !mABDict.ContainsKey(abName))
            {
                return(null);
            }

            string relativeDir = "AssetBundles/" + PTPlatformUtil.GetPlatformName();

            if (!string.IsNullOrEmpty(GroupName))
            {
                relativeDir += "/" + GroupName;
            }
            relativeDir += "/" + abName;

            string url = Path.Combine(Application.persistentDataPath, relativeDir);

            //先找可写路径
            if (File.Exists(url))
            {
                return(url);
            }

            //再找内存
            url = Path.Combine(Application.streamingAssetsPath, relativeDir);
            return(url);
        }
Ejemplo n.º 2
0
        public IEnumerator Load()
        {
//            if (ResMgr.SimulationMode)
//            {
//                SimulateLoad();
//                yield break;
//            }

            //1. load AssetBundleManifest
            string url = GetABUrl(string.IsNullOrEmpty(GroupName) ? PTPlatformUtil.GetPlatformName() : GroupName, true);

            mABManifestAB = AssetBundle.LoadFromFile(url);
            if (mABManifestAB == null)
            {
                Debug.LogError(">>>[ResKit]: AssetBundleManifest is not valid, please rebuild assetbundles.");
                yield break;
            }
            mABManifest = mABManifestAB.LoadAsset("AssetBundleManifest") as AssetBundleManifest;
            //mABManifestAB.Unload(false);

            //2. load res data
            url = GetAssetConfigUrl();
            string jsonText = null;

            if (!url.Contains("://"))
            {
                jsonText = File.ReadAllText(url);
            }
            else
            {
                using (WWW www = new WWW(url))
                {
                    yield return(www);

                    if (www.isDone)
                    {
                        if (!string.IsNullOrEmpty(www.error))
                        {
                            Debug.LogError(">>>[ResKit]: resdata.json is not valid.");
                            yield break;
                        }
                        jsonText = www.text;
                    }
                }
            }

            //3. parse res data
            ParseResData(JsonUtility.FromJson <ABDataList>(jsonText));
        }
Ejemplo n.º 3
0
        public string GetAssetConfigUrl()
        {
            string relativeDir = "AssetBundles/" + PTPlatformUtil.GetPlatformName();

            if (!string.IsNullOrEmpty(GroupName))
            {
                relativeDir += "/" + GroupName;
            }
            relativeDir += "/assetconfig.json";

            string url = Path.Combine(Application.persistentDataPath, relativeDir);

            //先找可写路径
            if (File.Exists(url))
            {
                return(url);
            }

            //再找内存
            url = Path.Combine(Application.streamingAssetsPath, relativeDir);
            return(url);
        }