Custom assertion for softptr fails even though it points to an asset

If you remove the checkf() does the DT get loaded and returned?

Looking at source it seems like IsValid on a TSoftObjectPtr would only return true when the object is already loaded:

	/**  
	 * Test if this points to a live UObject
	 *
	 * @return true if Get() would return a valid non-null pointer
	 */
	FORCEINLINE bool IsValid() const
	{
		// This does the runtime type check
		return Get() != nullptr;
	}

What you’re maybe looking for is IsNull - here’s what that one looks like in source:

	/**  
	 * Test if this can never point to a live UObject
	 *
	 * @return true if this is explicitly pointing to no object
	 */
	FORCEINLINE bool IsNull() const
	{
		return SoftObjectPtr.IsNull();
	}

Edit: I just realized the source I have on hand is 5.4.4, though I doubt it would be that different here

1 Like