Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dorgonman/700b83f04da2ca8865745d9430759e6e to your computer and use it in GitHub Desktop.
Save dorgonman/700b83f04da2ca8865745d9430759e6e to your computer and use it in GitHub Desktop.
{
FStringAssetReference testAssetRef = "/Game/UMG/NewWidgetBlueprint";
UObject* pObject = testAssetRef.TryLoad();
UWidgetBlueprint* pWidgetBlueprint = Cast<UWidgetBlueprint>(pObject);
auto widget = CreateWidget<UUserWidget>(this, pWidgetBlueprint->GeneratedClass);
// do something
//widget->AddToViewport();
FString pathName1 = FPackageName::LongPackageNameToFilename(pObject->GetPathName(), FPackageName::GetAssetPackageExtension());
FString pathName2 = FPackageName::LongPackageNameToFilename(pObject->GetOutermost()->GetPathName(), FPackageName::GetAssetPackageExtension());
}
{
FStringAssetReference testAssetRef = "/Game/UGameAssets/Assets/horizon/Maps/MainMap";
UObject* pObject = testAssetRef.TryLoad();
UWorld* pWorld = Cast<UWorld>(pObject);
FString pathName1 = FPackageName::LongPackageNameToFilename(pObject->GetPathName(), FPackageName::GetMapPackageExtension());
FString pathName2 = FPackageName::LongPackageNameToFilename(pObject->GetOutermost()->GetPathName(), FPackageName::GetMapPackageExtension());
}
{
FStringAssetReference testAssetRef = "/Game/UGameAssets/Assets/horizon/flipbook/hero_down";
UPaperFlipbook* pObject = Cast<UPaperFlipbook>(testAssetRef.TryLoad());
}
{
FStringAssetReference testAssetRef = "/Game/UGameAssets/Assets/horizon/spriter/MyTexture";
UTexture2D* pObject = Cast<UTexture2D>(testAssetRef.TryLoad());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment