public static DownloadAsBytesAsync ( string address ) : Task |
||
address | string | |
Результат | Task |
private async Task ShowRandomImages(int count, CancellationToken cancellationToken) { for (int i = 0; i < count; i++) { var image = await AsyncTools.DownloadAsBytesAsync("http://placeimg.com/320/200", cancellationToken); texture.LoadImage(image); rawImage.SetNativeSize(); counterText.text = $"{i + 1} of {count}"; if (i != count - 1) { await TaskEx.Delay(TimeSpan.FromSeconds(delayInSeconds), cancellationToken); } } }
public async void ShowGoogleLogosAsync() // can be on-click handler { button.interactable = false; var texture = new Texture2D(1, 1); rawImage.texture = texture; for (int i = 1; i <= 11; i++) { await .5f; var png = await AsyncTools.DownloadAsBytesAsync($"http://www.google.com/images/srpr/logo{i}w.png"); texture.LoadImage(png); rawImage.SetNativeSize(); } button.interactable = true; }