Monday, March 23, 2015

UI

Every project I've worked on, big (I've worked on the biggest) or small (I'm working on the smallest) I end up as a UI programmer.

This is a field that is always underestimated. It's your user's first experience of the game and frustrating menus and interactions are going to drive them away in droves.

Working as a solo developer on a small scale project I'm finding that as much as 50% of my time is spent on UI.

I'm working on it right now.

Don't underestimate it.

That is all.

Paper2d driven by C++

I couldn't find much information online about this hence the post.

Wanting to layer 2d images behind 3d actors in Unreal I found myself unable to do so using the Canvas draw commands. This led me to investigate Paper2d as when I started looking for information on applying textures to static meshes paper2d development articles started popping up.

However while Paper2d provides some pretty slick looking 2d tools I couldn't find any documentation about how to create sprites from C++.

So here's what it takes:

#include "PaperSpriteActor.h"
void CreateTestSprite(UTexture *pTestTexture, UWorld *pWorld, AActor *pOwner)
{
APaperSpriteActor* spawnedSprite = pWorld->SpawnActorDeferred<APaperSpriteActor>(APaperSpriteActor::StaticClass(), FVector::ZeroVector, FRotator(0.0f, 0.0f, 90.0f), pOwner);
if (spawnedSprite)
{
FSpriteAssetInitParameters initParams;
initParams.SetTextureAndFill((UTexture2D*)pTestTexture);
UPaperSprite *pNewSprite = (UPaperSprite *)StaticConstructObject(UPaperSprite::StaticClass(), spawnedSprite);
pNewSprite->InitializeSprite(initParams);
spawnedSprite->GetRenderComponent()->SetMobility(EComponentMobility::Movable);
spawnedSprite->GetRenderComponent()->SetSprite(pNewSprite);
spawnedSprite->SetActorScale3D(FVector(200.0f, 200.0f, 200.0f));
spawnedSprite->OnConstruction(spawnedSprite->GetTransform());
spawnedSprite->FinishSpawning(spawnedSprite->GetTransform());
}
}

One other thing to note (and this is very early days in my use of the system) is that an initial test with a 600x600 source texture left me with a blobby looking very low res image, while a 128x128 seems to draw as expected.