动态加载Object的工具方法
UTexture2D* MyTextureLoader::LoadTextureFromPath(const FString& Path)
{
if (Path.IsEmpty()) return NULL;
return Cast<UTexture2D>(StaticLoadObject(UTexture2D::StaticClass(), NULL, *(Path)));
}
FString PathToLoad = "/Game/Textures/MyRawMat";
UTexture2D* tmpTexture = LoadTextureFromPath(PathToLoad);
GetWorld()->GetFirstPlayerController(); 获取Level中所使用的player Controller
FVector2D ViewportSize = FVector2D(GEngine->GameViewport->Viewport->GetSizeXY());获取屏幕大小Vector
void AHUD::DrawTextureSimple(UTexture* Texture, float ScreenX, float ScreenY, float Scale, bool bScalePosition);在屏幕上画texture,其实只要Texture, ScreenX, ScreenY填上就有效果
IsValidLowLevel()函数,判断UObject对象指针,是否成为“悬空”指针,也就是野指针
void ShowWidget()//
{
if (false == this->IsInViewport())
{
AddToViewport();
}
if (false == this->IsVisible())
{
SetVisibility(ESlateVisibility::Visible);
}
}