예제 #1
0
    void LoadShipImage()
    {
        popup = Instantiate(imageDisplay, GameObject.FindGameObjectWithTag("Canvas").transform) as GameObject;
        ShipImagePopup shipImPop = popup.GetComponent <ShipImagePopup>();

        shipImPop.Appear();
        if (imageUrl != null)
        {
            StartCoroutine(LoadShipImageAsync());
        }
        else
        {
            shipImPop.infoText.text = "Image Unavailable";
        }
    }
예제 #2
0
    IEnumerator LoadShipImageAsync()
    {
        ShipImagePopup  shipPopup    = popup.GetComponent <ShipImagePopup>();
        UnityWebRequest imageRequest = UnityWebRequestTexture.GetTexture(imageUrl);

        yield return(imageRequest.SendWebRequest());

        if (imageRequest.isNetworkError || imageRequest.isHttpError)
        {
            shipPopup.infoText.text = "Unable To Load Image";
        }
        else
        {
            shipPopup.infoText.gameObject.SetActive(false);
            shipPopup.shipImage.sprite = SpriteFromTexture2D(((DownloadHandlerTexture)imageRequest.downloadHandler).texture);
            shipPopup.shipImage.gameObject.SetActive(true);
        }
    }