public static AssetBundleLoadAssetOperation LoadAssetAsync(string assetBundleName, string assetName, Type type) { AssetBundleManager.Initialize(); AssetBundleManager.LoadAssetBundle(assetBundleName, false); AssetBundleLoadAssetOperation assetBundleLoadAssetOperation = new AssetBundleLoadAssetOperationFull(assetBundleName, assetName, type); AssetBundleManager.m_InProgressOperations.Add(assetBundleLoadAssetOperation); return assetBundleLoadAssetOperation; }
public static void Initialize() { if (!AssetBundleManager.m_Instance) { AssetBundleManager.SetSourceAssetBundleURL(Path.GetFullPath(Application.dataPath).Replace("\\", "/") + "/AssetBundles/"); AssetBundleManager assetBundleManager = new GameObject("AssetBundleManager").AddComponent <AssetBundleManager>(); UnityEngine.Object.DontDestroyOnLoad(assetBundleManager); AssetBundleManager.m_Instance = assetBundleManager; AssetBundleLoadManifestOperation assetBundleLoadManifestOperation = AssetBundleManager.Initialize(Utility.GetPlatformName()); if (assetBundleLoadManifestOperation != null) { AssetBundleManager.m_Instance.StartCoroutine(assetBundleLoadManifestOperation); } } }
public static bool LoadAssetAsyncCallback <T>(string assetBundleName, string assetName, Func <T, bool> onAssetLoaded) where T : UnityEngine.Object { AssetBundleManager.Initialize(); if (AssetBundleManager.m_Instance) { if (string.IsNullOrEmpty(assetBundleName) || string.IsNullOrEmpty(assetName)) { Debug.LogError("## Empty bundle or asset name: assetBundleName=" + assetBundleName + ", assetName=" + assetName); return(false); } AssetBundleLoadAssetOperation assetBundleLoadAssetOperation = AssetBundleManager.LoadAssetAsync(assetBundleName, assetName, typeof(T)); if (assetBundleLoadAssetOperation != null) { if (!AssetBundleManager.m_PendingRoutines.ContainsKey(onAssetLoaded)) { Coroutine value = AssetBundleManager.m_Instance.StartCoroutine(AssetBundleManager.LoadAssetAsyncCallbackRoutine <T>(assetBundleName, assetBundleLoadAssetOperation, onAssetLoaded)); AssetBundleManager.m_PendingRoutines.Add(onAssetLoaded, value); } return(true); } } return(false); }
// Initialize the downloading url and AssetBundleManifest object. protected virtual IEnumerator Initialize() { // override this method for customizing your purpose. // Step 1. // If this test item intented to load a scene, // You may not want this game object (loader) to be destroyed. // Don't destroy this gameObject as we depend on it to run the loading script. DontDestroyOnLoad(gameObject); // Step 2. // Set the url before you initialize AssetBundleManager // With this code, when in-editor or using a development builds: Always use the AssetBundle Server // (This is very dependent on the production workflow of the project. // Another approach would be to make this configurable in the standalone player.) #if DEVELOPMENT_BUILD || UNITY_EDITOR AssetBundleManager.SetDevelopmentAssetBundleServer (); #else // Use the following code if AssetBundles are embedded in the project for example via StreamingAssets folder etc: AssetBundleManager.SetSourceAssetBundleURL(Application.dataPath + "/"); // Or customize the URL based on your deployment or configuration //AssetBundleManager.SetSourceAssetBundleURL("http://www.MyWebsite/MyAssetBundles"); #endif // Step 3. // Load the first manifest at Initialize(). // And defaultly AssetBundleManager will be generated as another game object // , and will not be destroyed. // Initialize AssetBundleManifest which loads the AssetBundleManifest object. var request = AssetBundleManager.Initialize(); if (request != null) yield return StartCoroutine(request); }
static public AssetBundleLoadManifestOperation Initialize() { instance = new GameObject("AssetBundleManager", typeof(AssetBundleManager)).GetComponent <AssetBundleManager>(); return(instance.Initialize(Utility.GetPlatformName())); }
private void Start() { abm = new AssetBundleManager(); abm.SetBaseUri("https://www.example.com/bundles"); abm.Initialize(OnAssetBundleManagerInitialized); }
public void InitializeInstance() { AssetBundleManager.Initialize(); }