Beispiel #1
0
        static bool InitializeBundle()
        {
            string relativePath = Path.Combine(Utility.AssetBundlesOutputPath, Utility.GetPlatformName());
            var    url          =
#if UNITY_EDITOR
                relativePath + "/";
#else
                Path.Combine(Application.streamingAssetsPath, relativePath) + "/";
#endif
            if (Bundles.Initialize(url))
            {
                var bundle = Bundles.Load("manifest");
                if (bundle != null)
                {
                    var asset = bundle.LoadAsset <TextAsset>("Manifest.txt");
                    if (asset != null)
                    {
                        using (var reader = new StringReader(asset.text))
                        {
                            manifest.Load(reader);
                            reader.Close();
                        }
                        bundle.Release();
                        Resources.UnloadAsset(asset);
                        asset = null;
                    }
                    return(true);
                }
                throw new FileNotFoundException("assets manifest not exist.");
            }
            throw new FileNotFoundException("bundle manifest not exist.");
        }
Beispiel #2
0
        static bool InitializeBundle()
        {
            string relativePath = Path.Combine(Settings.AssetBundlesOutputPath, Utility.GetPlatformName());
            var    url          = "";

#if UNITY_EDITOR
            if (Settings.ActiveBundleMode && Settings.ActiveDownloadMode)
            {
                url = Settings.AssetBunldesDownloadPath + "/";
            }
            else
            {
                url = relativePath + "/";
            }
#else
            if (Settings.ActiveDownloadMode)
            {
                url = Settings.AssetBunldesDownloadPath + "/";
            }
            else
            {
                url = Path.Combine(Application.streamingAssetsPath, relativePath) + "/";
            }
#endif
            if (Bundles.Initialize(url))
            {
                if (Settings.ActiveDownloadMode)
                {
                    string xManifestPath    = PatchManager.instance.localXManifestPath;
                    string xManifestContent = File.ReadAllText(xManifestPath);
                    if (xManifestContent.Length > 0)
                    {
                        using (var reader = new StringReader(xManifestContent)) {
                            manifest.Load(reader);
                            reader.Close();
                        }
                        return(true);
                    }
                }
                else
                {
                    var bundle = Bundles.Load("manifest");
                    if (bundle != null)
                    {
                        var asset = bundle.LoadAsset <TextAsset> ("Manifest.txt");
                        if (asset != null)
                        {
                            using (var reader = new StringReader(asset.text)) {
                                manifest.Load(reader);
                                reader.Close();
                            }
                            bundle.Release();
                            Resources.UnloadAsset(asset);
                            asset = null;
                        }
                        return(true);
                    }
                }
                throw new FileNotFoundException("assets manifest not exist.");
            }
            throw new FileNotFoundException("bundle manifest not exist.");
        }