TSoftClassPtr::ResetWeakPtr
#include "UObject/SoftObjectPtr.h"
Access: public
Specifiers: inline
Description
Clears only the cached weak object pointer while preserving the soft path string, forcing a fresh resolve on the next Get() call. Use this when the object's identity (FObjectID) may have changed without the path changing.
Caveats & Gotchas
- • The soft path is intentionally preserved — after calling ResetWeakPtr, IsNull() will still return false if a valid path was set, and IsPending() will return true until the class is loaded again.
- • This is primarily needed during editor hot-reload or live-coding scenarios where object pointers are remapped but paths remain stable; calling it at runtime in a shipping build is usually a no-op waste.
Signature
UE_FORCEINLINE_HINT void ResetWeakPtr() Return Type
void Example
Invalidating the weak cache after a hot reload C++
// Called when a module is reloaded in editor
void UMyAssetManager::OnModuleReloaded()
{
for (TSoftClassPtr<UObject>& Ptr : TrackedClasses)
{
Ptr.ResetWeakPtr(); // force re-resolve; paths stay intact
}
} Tags
Version History
Introduced in: 4.17
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?