Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

How can I use ConstructTexture2D in Console Builds?

I'm trying to create a UTexture2D from a CanvasRenderTarget2D instance which I've accomplished via CanvasRenderTarget2D::ConstructTexture2D in editor builds. When building for console, however, that function requires WITH_EDITORONLY_DATA be true because it uses PostEditChange(). So the function returns NULL.


So my question is, how can I make this work in console builds?

Edit: The most I could get working was this terribly performing function (needs to be called every tick ideally):

//Test UTexture2D* URuntimeCanvasRenderTarget2D::ConstructRuntimeTexture2D(UCanvasRenderTarget2D *target) { int Width = 256; int Height = 256;

 class UTexture2D* Result = UTexture2D::CreateTransient(

 FRenderTarget* RenderTarget = target->GameThread_GetRenderTargetResource();

 if (RenderTarget == NULL)
     return Result;

 // Lock the texture so it can be modified
 uint8* MipData = static_cast<uint8*>(Result->PlatformData->Mips[0].BulkData.Lock(LOCK_READ_WRITE));

 TArray<FColor> SurfData;

 // Create base mip.
 uint8* DestPtr = NULL;
 const FColor* SrcPtr = NULL;
 for (int32 y = 0; y<Height; y++)
     DestPtr = &MipData[(Height - 1 - y) * Width * sizeof(FColor)];
     SrcPtr = const_cast<FColor*>(&SurfData[(Height - 1 - y) * Width]);
     for (int32 x = 0; x<Width; x++)
         *DestPtr++ = SrcPtr->B;
         *DestPtr++ = SrcPtr->G;
         *DestPtr++ = SrcPtr->R;
         *DestPtr++ = SrcPtr->A;

 // Unlock the texture

 return Result;


Product Version: Not Selected
more ▼

asked Jun 27 '14 at 09:40 PM in C++ Programming

avatar image

18 3 4 9

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question