Simple 2D streaming assets image

Is there not a script for loading an image from the Streaming Assets folder that is as simple as loading the video player? I’ve looked all over, and none of the tutorials or assets from the asset store are working for me. They either use www (which Unity is telling me is obsolete) or they don’t apply at all to what I want to do (I need 2D only right now) or they were created in older versions of Unity with errors popping up. I just want one image from the Streaming Assets folder for a super simple program. It should be easy (even for a noob like me), but I’m soooo stuck and frustrated.

using System.Collections;
using System.IO;
using UnityEngine;
using UnityEngine.Networking;

[RequireComponent(typeof(Mesh))]

public class LocalImageGet : MonoBehaviour
{
private UnityEngine.Texture2D texture;

void Start()
{
StartCoroutine(LoadTexture());
}

private IEnumerator LoadTexture()
{
GameObject img = GameObject.Find(“RawImage”);

// Creates a 2D texture with width and height scale.
Texture2D texture = new Texture2D(1, 1);

string uri = System.IO.Path.Combine(Application.streamingAssetsPath, “image1”);

using (var uwr = UnityWebRequestTexture.GetTexture(uri))
{
uwr.downloadHandler = new DownloadHandlerTexture();
yield return uwr.SendWebRequest();

GetComponent().material.mainTexture = DownloadHandlerTexture.GetContent(uwr);
}
}

}

In the above example, I basically threw everything at it. The image still does not show up, and I get an error that the image hasn’t finished loading (which doesn’t make sense), so the last line of code can’t execute.

What is the size of the image? If the image is too large, it is possible it has not finished loading before you are trying to use it.

Thanks for the reply. The size of the image wan’t too big. I’m just so new to this, that I often have to fumble my way to success. I figured it out, finally. I had no choice but to use the obsolete www method. So it works, now. I just have to ignore the error messages. So this is basically it…

{
string url = System.IO.Path.Combine(Application.streamingAssetsPath, “image1.png”);
WWW www = new WWW(url);
Texture2D texture = www.texture;

GetComponent().sprite = TextureToSprite(texture);

}
Sprite TextureToSprite(Texture2D texture)
{
Rect rect = new Rect(0, 0, texture.width, texture.height);
Vector2 pivot = new Vector2(0.5f, 0.5f);
Sprite sprite = Sprite.Create(texture, rect, pivot);
return sprite;
}