/// <summary> /// 设置开发模式下资源服务器地址,对应“AssetBundleManager/Resources/AssetBundleServerURL”文件配置 /// </summary> public static void SetDevelopmentAssetBundleServer() { #if UNITY_EDITOR // If we're in Editor simulation mode, we don't have to setup a download URL // 如果在编辑器模式,且处于模式模式,不设置下载url地址 if (SimulateAssetBundleInEditor) { return; } #endif TextAsset urlFile = Resources.Load("AssetBundleServerURL") as TextAsset; string url = (urlFile != null) ? urlFile.text.Trim() : null; if (url == null || url.Length == 0) { Debug.LogError("Development Server URL could not be found."); //如果未配置,可以取消以下注释,使用本地url地址 //AssetBundleManager.SetSourceAssetBundleURL("http://localhost:7888/" + UnityHelper.GetPlatformName() + "/"); } else { // 设置源资源URL地址 AssetBundleManager.SetSourceAssetBundleURL(url); } }
public static void SetDevelopmentAssetBundleServer() { #if UNITY_EDITOR // If we're in Editor simulation mode, we don't have to setup a download URL if (SimulateAssetBundleInEditor) return; #endif if(IsLoadFromStream)//从steam文件夹; { AssetBundleManager.SetSourceAssetBundleDirectory(); } else { TextAsset urlFile = Resources.Load("AssetBundleServerURL") as TextAsset; string url = (urlFile != null) ? urlFile.text.Trim() : null; if (url == null || url.Length == 0) { Debug.LogError("Development Server URL could not be found."); //AssetBundleManager.SetSourceAssetBundleURL("http://localhost:7888/" + UnityHelper.GetPlatformName() + "/"); } else { AssetBundleManager.SetSourceAssetBundleURL(url); } } }
public static void SetDevelopmentAssetBundleServer() { TextAsset urlFile = Resources.Load("AssetBundleServerURL") as TextAsset; string url = (urlFile != null) ? urlFile.text.Trim() : null; if (url == null || url.Length == 0) { Debug.LogError("Development Server URL could not be found."); } else { AssetBundleManager.SetSourceAssetBundleURL(url); } }
public static void SetDevelopmentAssetBundleServer() { TextAsset urlFile = Resources.Load("AssetBundleServerURL") as TextAsset; string url = (urlFile != null) ? urlFile.text.Trim() : null; if (url == null || url.Length == 0) { Debug.LogError("Development Server URL could not be found."); //AssetBundleManager.SetSourceAssetBundleURL("http://localhost:7888/" + UnityHelper.GetPlatformName() + "/"); } else { AssetBundleManager.SetSourceAssetBundleURL(url); } }
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); } } }
/// <summary> /// Sets base downloading URL to a local development server URL. /// </summary> public static void SetDevelopmentAssetBundleServer() { #if UNITY_EDITOR // If we're in Editor simulation mode, we don't have to setup a download URL if (SimulateAssetBundleInEditor) { return; } #endif TextAsset urlFile = Resources.Load("AssetBundleServerURL") as TextAsset; string url = (urlFile != null) ? urlFile.text.Trim() : null; if (url == null || url.Length == 0) { Log(LogType.Error, "Development Server URL could not be found."); } else { AssetBundleManager.SetSourceAssetBundleURL(url); } }
//设置开发资源服务; public static void SetDevelopmentAssetBundleServer() { /* #if UNITY_EDITOR * // If we're in Editor simulation mode, we don't have to setup a download URL * // 如果我们在编辑器模式下,我们不用设置下载URL * if (SimulateAssetBundleInEditor) * return; #endif */ //从Resources目录下加载AssetBundleServerURL文件 TextAsset urlFile = Resources.Load("AssetBundleServerURL") as TextAsset; string url = (urlFile != null) ? urlFile.text.Trim() : null; if (url == null || url.Length == 0) { Debug.LogError("Development Server URL could not be found."); //AssetBundleManager.SetSourceAssetBundleURL("http://localhost:7888/" + UnityHelper.GetPlatformName() + "/"); } else { AssetBundleManager.SetSourceAssetBundleURL(url); } }
// 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); }