Anyone know how to load an image from file at runtime into Scaleform html text field?

Please note this is regarding UDK or UE3, i.e., NOT UE4 or UE5.

I have implemented Steamworks and I am able to call SteamInput()->GetGlyphForActionOrigin_Legacy() to get the path to the image I want to display for my tutorial. Just for example, character movement is done with the controller left stick, and that function call gives me a path to the file shared_lstick_md.png in the Steam folder. The problem is I can’t display that image from the file. I can’t do it using the html img tag in TextField.htmlText and I can’t do it using the Actionscript Loader or UILoader classes.

Did one of you figure out how to load images dynamically into the UI at runtime? I think I remember hearing how one of you loaded friends’ portraits at runtime.

1 Like

This might help you. I read the avatar images from Steam. Here’s the async callback:

//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//Cache a ref to the downloaded avatar image.
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
simulated function OnReadOnlineAvatarComplete(const UniqueNetId playerNetId, Texture2D _avatar)
{
    Avatar = _avatar;
}

Then i generate the uri to use in AS3 like this (still in unrealscript):

//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//Builds the resource url for the avatar image.
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
simulated function String GetAvatarSourcePath()
{
	if (Avatar != none) {
		return "img://" $ Avatar.GetPackageName() $ "." $ Avatar.Name;
	}
	return "";
}

Then in AS3, i use UILoader:

var AvatarImg = new UILoader();
AvatarImg.source = sourcePath;//What i pulled from GetAvatarSourcePath() in Unrealscript.
addChild(AvatarImg);

Hope that helps.

1 Like

That looks great. But there are some things I’m not clear about.

The Steam callback… it returns a Texture2D? Does it download the texture file somewhere to your local drive? And then you can access it without importing it into the editor? The function that calls OnReadOnlineAvatarComplete, how did it convert a downloaded file into an accessible Texture2D object? How can I access a file as a Texture2D without importing it into the editor first?

1 Like

A bit late response, but you can definitely download images in real time and use them in-game. See the Ipdrv\OnlineImageDownloaderWeb.uc file. I instanced that and put a single URL in an array to RequestOnlineImages() and I got the image as a texture and could draw it on screen using Canvas. Seems to be coded to only work with JPEGs though.

2 Likes

You are really a genius.

Excellent! Thanks @NodSaibot

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.