Exemplo n.º 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.");
        }
Exemplo n.º 2
0
 protected override void OnLoad()
 {
     request = Bundles.Load(Assets.GetBundleName(assetPath));
     if (Assets.IsTjFrame)
     {
         asset = request.LoadAsset(assetPath, assetType);
     }
     else
     {
         asset = request.LoadAsset(Assets.GetAssetName(assetPath), assetType);
     }
     //   asset = request.LoadAsset(Assets.GetAssetName(assetPath), assetType);
 }
Exemplo n.º 3
0
 protected virtual void OnInit(bool loadDependencies)
 {
     _assetBundle = AssetBundle.LoadFromFile(Bundles.GetDataPath(name) + name);
     if (_assetBundle == null)
     {
         error = name + " LoadFromFile failed.";
     }
     if (loadDependencies)
     {
         var items = Bundles.manifest.GetAllDependencies(name);
         if (items != null && items.Length > 0)
         {
             for (int i = 0, I = items.Length; i < I; i++)
             {
                 var item = items [i];
                 dependencies.Add(Bundles.Load(item));
             }
         }
     }
 }
Exemplo n.º 4
0
 protected override void OnInit()
 {
     request = Bundles.Load(Assets.GetBundleName(assetPath));
     asset   = request.LoadAsset(Assets.GetAssetName(assetPath), assetType);
 }
Exemplo n.º 5
0
 public void Load()
 {
     bundle = Bundles.Load(bundleName);
 }
Exemplo n.º 6
0
 internal void Load(bool loadDependencies)
 {
     I("Load " + name);
     OnLoad(loadDependencies);
     if (loadDependencies)
     {
         var items = Bundles.manifest.GetAllDependencies(name);
         if (items != null && items.Length > 0)
         {
             for (int i = 0, max = items.Length; i < max; i++)
             {
                 var item = items[i];
                 dependencies.Add(this is BundleAsync ? Bundles.LoadAsync(item) : Bundles.Load(item));
             }
         }
     }
 }
Exemplo n.º 7
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.");
        }