Create a sprite at runtime?

I’ve seen multiple questions on the issue, but none that answer my question.

I want to load in an image from outside the resouce folder using WWW and then create a new sprite class to set into the scene. I tried to do

            www = new WWW("file://" + file);
        yield return www;
        Sprite sprite = Sprite.Create
            new Rect(0, 0, www.texture.width, www.texture.height),
            new Vector2(www.texture.width * 0.5f, www.texture.height * 0.5f),

but when I set the sprite to a sprite render such as this:

GameObject obj = new GameObject();
                            obj.transform.position = mousePos;

                            SpriteRenderer sprite = obj.AddComponent<SpriteRenderer>();
                            sprite.sprite = _currentTile.Image;

Where _currentTile.Image is a Sprite variable loaded in with WWW it shows nothing on the screen. I checked the hierarchy and they are in the right position, however no image will show up for them.

What would be the way to accomplish this?

Thank you!

Edit: found the solution.

the sprite was made, however the Vector2 is percentage based, not pixel based (from 0 - 1). So I had the center of the image set to 640% (128x128 image). by changing new Vector2(www.texture.width * 0.5f, www.texture.height * 0.5f), to new Vector2(0.5f, 0.5f) it worked.

Have you checked this out?
Sprite at runtime

You could also have an empty game object with a sprite renderer component already attached as a prefab. Then just load the prefab and attach the image when ready.