Andreas Grois<p>I was shocked when I saw that the <a href="https://mastodon.gamedev.place/tags/PlayFab" class="mention hashtag" rel="tag">#<span>PlayFab</span></a> <a href="https://mastodon.gamedev.place/tags/UnrealEngine" class="mention hashtag" rel="tag">#<span>UnrealEngine</span></a> plugin uses a TSharedPtr<UPlayFabAuthenticationContext>, where the UPlayFabAuthenticationContext is a UObject.</p><p>I always thought this to be impossible.</p><p>They use this <a href="https://mastodon.gamedev.place/tags/Hack" class="mention hashtag" rel="tag">#<span>Hack</span></a> to make it work:<br />- First create a TSharedRef<TStrongObjectPtr<UObject>>.<br />- Then use the aliasing constructor <br />TSharedPtr(TSharedPtr<OtherType>, ObjectType*) to create a new shared pointer using the Shared Reference as first, and the UObject as second parameter.<br /><a href="https://mastodon.gamedev.place/tags/GameDev" class="mention hashtag" rel="tag">#<span>GameDev</span></a></p>