Hey guys,
I feel like a real idiot regarding this, but I have NO idea how to access Paper2D classes in my code.
I looked at this tutorial, https://wiki.unrealengine.com/An_Introduction_to_UE4_Plugins#Non-Game_Module
but I’m not sure if any of it’s even relevant to accessing Paper2D stuff in code?
I’m using Unreal Engine 4.1 and have enabled the Paper2D plug-in
So yeah my question basically is, step-by-step, how do I access Paper2D classes in my own code?
Did you get anywhere with this?
I’ve got as far as trying to create a APaperSpriteActor and set the sprite on the rendercomponent but am getting exceptions thrown when I call InitializeSprite on the newly created sprite. Some sample code would definitely save me a bunch of trial and error getting this right!
In case others get here following the same path as me this gets somewhere:
void CreateTestSprite(UTexture *pTestTexture, UWorld *pWorld, AActor *pOwner)
{
APaperSpriteActor* spawnedSprite = pWorld->SpawnActorDeferred<APaperSpriteActor>(APaperSpriteActor::StaticClass(), FVector::ZeroVector, FRotator::ZeroRotator, 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());
}
}
CtnDev
(CtnDev)
December 26, 2019, 10:05pm
4
For long time check, I have put solution in Forum. Check this out.