Skip to content

Instantly share code, notes, and snippets.

@TakaakiIchijo
Created July 27, 2017 07:42
Show Gist options
  • Save TakaakiIchijo/90863dcaf5348d8d2feee1860f656575 to your computer and use it in GitHub Desktop.
Save TakaakiIchijo/90863dcaf5348d8d2feee1860f656575 to your computer and use it in GitHub Desktop.
サーバー(NCMBファイルストア)から5000兆円を取得する
using System.Collections;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
public class UnityWebRequestTest : MonoBehaviour
{
public Image image;
private void Start()
{
StartCoroutine(Get());
}
private IEnumerator Get()
{
UnityWebRequest request = UnityWebRequest.Get("https://mb.api.cloud.nifty.com/2013-09-01/applications/lMl9nJk3R53h8EDc/publicFiles/5000chouen.png");
yield return request.Send();
#if UNITY_2017_1_OR_NEWER
if (request.isNetworkError)
#else
if (request.isError)
#endif
{
Debug.Log(request.error);
}
else
{
Texture2D texture = new Texture2D(800, 400);
texture.LoadImage(request.downloadHandler.data);
image.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment