• Work
  • About
  • Contact

Adriana G Rivera

AR/VR Software Developer

  • Work
  • About
  • Contact

Adding the ability to pull images from the inter-webs

Today was a difficult Monday. Nothing in particular happened today, I found it just difficult to focus. This past weekend I spent relaxing mostly by myself. I finally got around to trying out Monster Hunter World, which is super fun. It has an alarming amount of depth, and the monsters are beautifully crafted in every way, and hella fun to fight. I’m a personal fan of the Insect Glaive, as the ridiculous mobility is my jam. I also played DnD at my local Adventurers League like the nerd I am, and had a blast. Some dude there had a Kronk impression that was on point. good times all around.

Actual Code Stuff


I wanted to work on my DnD viewer today, but it was being awfully difficult to build on my laptop today, so I just kept chipping away at this project. I thought, how could I expand the textures the user has access to for this? My dopey 3 are cool and all, but what if they could see ALL of them? So, a lil script that allows you to enter a string into an Input field will make a web request and pull down a texture.

using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Networking;

public class PullTextureFromInternet : MonoBehaviour
{
    #region Variables
    public string url;
    [SerializeField]
    private Texture myTexture;
    #endregion

    #region Unity Functions
    #endregion

    #region Custom Functions
    public void CallForTexture()
    {
        url = GameObject.FindObjectOfType<InputField>().text;
        StartCoroutine(PullTexture());
    }

    private IEnumerator PullTexture()
    {
        UnityWebRequest www = UnityWebRequestTexture.GetTexture(url);
        yield return www.SendWebRequest();

        if (www.isNetworkError || www.isHttpError)
            Debug.Log(www.error);
        else
            myTexture = ((DownloadHandlerTexture)www.downloadHandler).texture;
    }
    #endregion
}
Monday 01.14.19
Posted by Adriana Rivera
Newer / Older

Powered by Squarespace.