Scripted textures
This is a way to draw pixels directly to a surface.
Note
When you draw to a texture, all surfaces using that texture will be updated. You will therefore need one ScriptedTexture per "canvas" you want to draw onto.
Prerequisites:
Script
First, create a controller that draws stuff:
class DynamicTextureController extends Info;
var() Texture ScriptedTexture;
simulated function PostPostBeginPlay()
{
if(ScriptedTexture != None)
ScriptedTexture(ScriptedTexture).NotifyActor = Self;
}
simulated function Destroyed()
{
if(ScriptedTexture != None)
ScriptedTexture(ScriptedTexture).NotifyActor = None;
}
simulated event RenderTexture(ScriptedTexture Tex)
{
local Color Col;
// Parameters: x, y, width, height, source x, source y, source width, source height, source texture, masked
Tex.DrawTile(10, 40, 20, 20, 0, 0, 1, 1, Texture'Solid', False);
Col.R = 255;
Col.G = 255;
Col.B = 255;
Tex.DrawColoredText(20, 20, "TEST!", Font'FontMenuExtraLarge', Col);
}
defaultproperties
{
RemoteRole=ROLE_SimulatedProxy
bStatic=False
bAlwaysRelevant=True
bNoDelete=True
}
UnrealEd
- Create an instance of your DynamicTextureController in your map
- Import a 256x256 texture into a texture package (usable colours will be limited to those present in the palette)
- Create a new image in your texture package of the type "ScriptedTexture"
- In the new properties window, expand
ScriptedTexture
and setSourceTexture
to the one you created in step 2 - Save your texture package
- Apply your ScriptedTexture onto a surface in your map
- Open the properties for your DynamicTextureController actor and assign the ScriptedTexture to the
ScriptedTexture
property - Build and run
Overview
This is a little checklist to ensure everything is hooked up correctly.
Your texture package:
- Has a normal texture with a palette of at least a few colours
- Has a ScriptedTexture with the SourceTexture set to the above texture
Your texture controller:
- Has the ScriptedTexture (not the normal one) from your texture package assigned as the "ScriptedTexture" property
Your brush:
- Has the ScriptedTexture applied to its surface (again, not the normal one)
- Has the surface scaled/panned so the contents of the ScriptedTexture can be seen