# Textures not visible when packaged but visible in PIE

**URL:** <https://forums.unrealengine.com/t/textures-not-visible-when-packaged-but-visible-in-pie/44768>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [October 15, 2015, 3:29pm UTC](https://forums.unrealengine.com/t/textures-not-visible-when-packaged-but-visible-in-pie/44768 "2015-10-15T15:29:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jerry.Richards](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jerry.Richards](https://forums.unrealengine.com/u/Jerry.Richards)\
**Post date:** [October 15, 2015, 3:29pm UTC](https://forums.unrealengine.com/t/textures-not-visible-when-packaged-but-visible-in-pie/44768/1 "2015-10-15T15:29:43Z")

</div>

Hello All.

Textures for Achievements, or Level Icon textures don’t load properly when the game is packaged for Windows but do work when testing with PIE. These textures are “dynamically” loaded using the following code:

```auto

UTexture2D* UMyGameInstance::LoadTexture(TAssetPtr<UTexture2D> Asset)
{
    if (Asset.IsPending())
    {
        const FStringAssetReference& AssetRef = Asset.ToStringReference();
        Asset = Cast<UTexture2D>(AssetLoader.SynchronousLoad(AssetRef));
    }

    return Asset.Get();
}

void UMyGameInstance::LoadAchievementTextures()
{
    LoadTexture(Achievement1);
    LoadTexture(Achievement2);
    LoadTexture(Achievement3);
    :
    :
}

```

These textures are not a power of two as they are UI textures. Do they need to be converted to ^2? Anything else I can do to get the textures to load properly?

Thank you.

EDIT [2015.10.15.12:12:00]

I now know it has nothing to do with power of 2 textures. It may be more to do with the garbage collector more than anything else. I managed to get the textures loaded, and visible in the UI. However, after coming back from gameplay the textures are white again.

---

<div class="post-metadata">

**Author:** ![Jerry.Richards](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jerry.Richards](https://forums.unrealengine.com/u/Jerry.Richards)\
**Post date:** [October 15, 2015, 8:18pm UTC](https://forums.unrealengine.com/t/textures-not-visible-when-packaged-but-visible-in-pie/44768/2 "2015-10-15T20:18:38Z")

</div>

It appears to be with TAssetPtr usage. Possibly I’m not using it correctly. Two major changes that I made were to switch from initialing loading the textures to loading them on each call. That is, when a specific texture is requested to call my LoadTexture function:

```auto

UTexture2D* UMyGameInstance::LoadTexture(TAssetPtr<UTexture2D> Asset)
{
    if (Asset.IsPending() || !Asset.IsValid())
    {
        const FStringAssetReference& AssetRef = Asset.ToStringReference();
        Asset = Cast<UTexture2D>(AssetLoader.SynchronousLoad(AssetRef));
    }

    return Asset.Get();
}

```

Upon initial startup this works fine. However, stating the game and returning back to the menu causes the game to crash. Should the code be reworked to:

```auto

UTexture2D* UMyGameInstance::LoadTexture(TAssetPtr<UTexture2D> Asset)
{
    if(!Asset.IsPending() && !Asset.IsValid())
    {
        Asset.Reset();
    }

    if (Asset.IsPending() || !Asset.IsValid())
    {
        const FStringAssetReference& AssetRef = Asset.ToStringReference();
        Asset = Cast<UTexture2D>(AssetLoader.SynchronousLoad(AssetRef));
    }

    return Asset.Get();
}

```

---

<div class="post-metadata">

**Author:** ![Jerry.Richards](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jerry.Richards](https://forums.unrealengine.com/u/Jerry.Richards)\
**Post date:** [October 15, 2015, 9:18pm UTC](https://forums.unrealengine.com/t/textures-not-visible-when-packaged-but-visible-in-pie/44768/3 "2015-10-15T21:18:58Z")

</div>

This works:

```auto

UTexture2D* UMyGameInstance::LoadTexture(TAssetPtr<UTexture2D> Asset)
{
    return Asset.LoadSynchronous();
}

```

So instead of using FStreamableManager, TAssetPtr::LoadSynchronous works the best. Actually, it appears to work really well.

And if you’re inclined to read up on loading assets, I’d like to suggest the following:

> **[Referencing Assets](https://docs.unrealengine.com/5.2/en-US/referencing-assets-in-unreal-engine/)**
>
> Control how an asset is referenced and loaded into memory.

[https://docs.unrealengine.com/latest/INT/Programming/Assets/AsyncLoading/index.html](https://docs.unrealengine.com/latest/INT/Programming/Assets/AsyncLoading/index.html)

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — https://unrealcommunity.wiki/! You will be able to find content from...

And what has become my personal favorite:

> **[TAssetPtr](https://docs.unrealengine.com/5.2/en-US/API/Runtime/CoreUObject/UObject/TAssetPtr/)**
>
> Not deprecating these yet as it will lead to too many warnings in games
