Hi everyone,
I have been messing around with the textures off and on now for a couple weeks and I’ve hit a road block. My situation is that I would like to set the texture within the editor, and then display the texture within my inventory drawing with Canvas. But when I open my inventory, the texture does not display, but if I was to view the details of the texture first and then open my inventory the texture displays. Also if I Cast(StaticLoadObject(UTexture2D::StaticClass(), NULL, *(emptyTexturePath)));
the texture displays instantly.
This is the declaration of the texture when setup from the editor
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Texture)
TAssetPtr<UTexture2D> Texture;
And in the HUD this is the code that sets the texture when it draws the inventory:
items[i].emptyTextureButton = item->Texture.Get();
I’ve tried this and setting the Mip, locking the Mip, and them Mmcpy(Data, NewData, DataSize) and nothing. As well I attempted to do do CreateTransient() but with that I receive an exception. I’ve looked at the following but the UpdateTextureRegions errors out for me as well:
FUpdateTextureRegion2D r(0, 0, 0, 0, textureDimensions, textureDimensions);
uint8 temp = 4;
uint8* data = &temp;
UpdateTextureRegions(texture, (int32)0, (uint32)1, &r, (uint32)(4 * textureDimensions), (uint32)4, data, false); // Using the UpdateTextureRegions from https://wiki.unrealengine.com/Dynamic_Textures
texture->UpdateResource();
items[i].emptyTextureButton = texture;
But the last one I think I was just missing something. I know there was a documentation page about asset pointer or dynamically loading (can’t find the url currently) and I tried following that but I wasn’t seeing the connection with that one.
If someone could direct me in the right way or explain what I am doing incorrect that would be very helpful. I am using Ver 4.1.0 and I will not be able to respond until a couple days as I have limit internet access.
Thanks everyone