SetDevelopmentAssetBundleServer() public static method

public static SetDevelopmentAssetBundleServer ( ) : void
return void
コード例 #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);
                    }
                }
            }
        }
コード例 #2
0
	// 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);
	}