UE4.19
.h
UCLASS()
class SZMUEDESIGN_API UMyBPFLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
UFUNCTION(BlueprintPure, Category = " vc library")
static bool BLGetPartTexture(const UTexture2D* texture, UTexture2D* newTexture2D, const FVector2D rectStartPoint, const float rectWidth, const float rectHeight);
.cpp
bool UMyBPFLibrary::BLGetPartTexture(const UTexture2D* texture, UTexture2D* newTexture2D, const FVector2D rectStartPoint, const float rectWidth, const float rectHeight)
{
if (!texture->IsValidLowLevel())
{
//If used, delete the original object
texture->BeginDestroy();
}
……………………
}
}
Function:Intercept the texture of the specified rectangular area and return to newTexture2D。
I passed in a texture map from the blueprint and specified the data for segmentation. C ++ prompts wrong parameters.
Questions are as follows:
- How to transfer UTexture2D from blueprint?
- Because Utexture2D needs to set properties in order to access pixel by pixel. For example CompressionSettings. How should this be achieved?
3.If the texture2D object is released for new creation?