Static_cast error

I have the line of code below to access a texture content directly, and it compiles and works perfectly when playing in editor.

FColor* MazeLayout = static_cast<FColor*>(Layout->PlatformData->Mips[0].BulkData.Lock(LOCK_READ_ONLY));

However when I try to package to ship I get the following error:

UATHelper: Packaging (iOS):     [113/541] Compile MazeOnGameModeBase.cpp
 UATHelper: Packaging (iOS):     C:\Users\aless\Documents\Unreal Projects\MazeOn\Source\MazeOn\MasterMaze.cpp:84:23: error: static_cast from 'unsigned char *' to 'FColor *' is not allowed
 UATHelper: Packaging (iOS):             FColor* MazeLayout = static_cast<FColor*>(Layout->PlatformData->Mips[0].BulkData.Lock(LOCK_READ_ONLY));
 UATHelper: Packaging (iOS):                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 PackagingResults: Error: static_cast from 'unsigned char *' to 'FColor *' is not allowed
 UATHelper: Packaging (iOS):     [114/541] Compile MasterMaze.gen.cpp

Any ideas on how to solve this?

Maybe it just doesnt like static cast, have you tried reinterpret_cast ?

2 Likes

You are an absolute legend - changing it to reinterpret_cast worked perfectly! Thanks a lot!

1 Like

Nice, converted to answer if you want to mark it solved :wink:

This totally works! Thanks a bunch!