AssetBundles.AssetBundleManager.SetDevelopmentAssetBundleServer C# (CSharp) Method

SetDevelopmentAssetBundleServer() public static method

public static SetDevelopmentAssetBundleServer ( ) : void
return void
        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)
            {
                Debug.LogError("Development Server URL could not be found.");
                //AssetBundleManager.SetSourceAssetBundleURL("http://localhost:7888/" + UnityHelper.GetPlatformName() + "/");
            }
            else
            {
                AssetBundleManager.SetSourceAssetBundleURL(url);
            }
        }

Usage Example

Beispiel #1
0
        public IEnumerator CollectDownloadFile()
        {
            UnityWebRequest request = UnityWebRequest.Get(GetVersionFileUrl(LoaderSpace.Streaming));

            yield return(request.SendWebRequest());

            string versionText = DownloadHandlerBuffer.GetContent(request);

            streamingVersion = GetAssetBundleVersion(versionText, LoaderSpace.Streaming);

            print(Application.persistentDataPath);
            print(GetVersionFileUrl(LoaderSpace.Persistent));
            request = UnityWebRequest.Get(GetVersionFileUrl(LoaderSpace.Persistent));
            yield return(request.SendWebRequest());

            print(request.error);
            if (string.IsNullOrEmpty(request.error))
            {
                versionText = DownloadHandlerBuffer.GetContent(request);
                print(versionText);
                persistentVersion = GetAssetBundleVersion(versionText, LoaderSpace.Persistent);
            }

            AssetBundleManager.SetDevelopmentAssetBundleServer();

            request = UnityWebRequest.Get(GetVersionFileUrl(LoaderSpace.Server));
            print(GetVersionFileUrl(LoaderSpace.Server));
            yield return(request.SendWebRequest());

            versionText   = DownloadHandlerBuffer.GetContent(request);
            serverVersion = GetAssetBundleVersion(versionText, LoaderSpace.Server);

            DownloadTotalSize = 0;
            foreach (var item in serverVersion)
            {
                if (persistentVersion.ContainsKey(item.Key))
                {
                    if (!string.Equals(item.Value.hash, persistentVersion[item.Key].hash))
                    {
                        DownloadTotalSize += item.Value.size;
                        mDownloadAssetBundleVersion.Add(item.Value);
                    }
                }
                else
                {
                    AssetBundleVersion streamInfo = null;
                    streamingVersion.TryGetValue(item.Key, out streamInfo);
                    if (streamInfo == null || !string.Equals(item.Value.hash, streamInfo.hash))
                    {
                        DownloadTotalSize += item.Value.size;
                        mDownloadAssetBundleVersion.Add(item.Value);
                    }
                }
            }
        }
All Usage Examples Of AssetBundles.AssetBundleManager::SetDevelopmentAssetBundleServer