I’m getting this weird issue when trying to add an item to a TArray on my component.
So I have a component that I’ve added to a character in in blueprint. This component comes from a plugin that I created. This component contains a list:
UPROPERTY(Instanced, EditAnywhere, BlueprintReadWrite, meta = (AllowPrivateAccess = “true”))
TArray<TObjectPtr> LoadoutSlots;
Now when trying to add an item the correct option shows up but when clicking it nothing happens and it doesn’t get added.
I tried just adding that list directly on the player and not use the component from the plugin and that works, so it seems to be a plugin issue.
The weird thing is I’ve been able to add the item properly in the past but this issue seems to happen randomly.
Hi Cheetor2502,
Are you sure you’re wanting the pointer as a TObjectPtr? Here is the description in the source code:
- TObjectPtr is a type of pointer to a UObject that is meant to function as a drop-in replacement for raw pointer
- member properties. It is size equivalent to a 64-bit pointer and supports access tracking and optional lazy load
- behavior in editor builds. It stores either the address to the referenced object or (in editor builds) an index in
- the object handle table that describes a referenced object that hasn’t been loaded yet. It is serialized
- identically to a raw pointer to a UObject. When resolved, its participation in garbage collection is identical to a
- raw pointer to a UObject.
- This is useful for automatic replacement of raw pointers to support advanced cook-time dependency tracking and
- editor-time lazy load use cases. See UnrealObjectPtrTool for tooling to automatically replace raw pointer members
- with FObjectPtr/TObjectPtr members instead.
Have you tried defining it as TArray<TWeakObjectPtr> to see if it is handled correctly like that?
Hello RecourseDesign,
In this case I don’t think I can use TWeakObjectPtr if the UPROPERTY is Instanced.
The part that confuses me about this issue is that if I move this code into the game directly and not through a plugin it works as expected.
I encountered a similar issue. The object class that the array was made up of had a property with a nested category.
Example:
UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "Main|SubCategory")
bool m_bSomeBool = true;
Removing the nested category fixed the issue.
“Main|SubCategory” → “MainSubCategory”
Hello DF_JGregg,
Unfortunately for me the object class doesn’t have a nested category.
What is the UObject class behind LoadoutSlots?
It should be something more like this:
TArray<TObjectPtr<ULyraSlot>> LoadoutSlots;