# AddReferenceObject vs. AddReferencedObjects

**URL:** <https://forums.unrealengine.com/t/addreferenceobject-vs-addreferencedobjects/42283>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [September 19, 2015, 10:20pm UTC](https://forums.unrealengine.com/t/addreferenceobject-vs-addreferencedobjects/42283 "2015-09-19T22:20:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Laphicet\_Crowe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Laphicet\_Crowe](https://forums.unrealengine.com/u/Laphicet_Crowe)\
**Post date:** [September 19, 2015, 10:20pm UTC](https://forums.unrealengine.com/t/addreferenceobject-vs-addreferencedobjects/42283/1 "2015-09-19T22:20:54Z")

</div>

Some things such as TSets and TMaps aren’t supported by UPROPERTY. I’ve read that I had to implement `static void AddReferencedObjects(UObject *InThis, FReferenceCollector &Collector);`, which I did, but looking at some uses of it in UE4’s github, as well as documentation, I’m not real clear on the difference of FReferenceCollector::AddReferencedObject and FReferenceCollector::AddReferencedObjects.

Additionally, I was wondering if I have to call the reimplemented function at some point in my code or if the UObject ancestor class handles it automatically? I also have an enum with bitfields beyond value 255 and since I can’t use it as a UPROPERTY either, do I need to have that ref collected as well, or are value types not collected?

---

<div class="post-metadata">

**Author:** ![Laphicet\_Crowe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Laphicet\_Crowe](https://forums.unrealengine.com/u/Laphicet_Crowe)\
**Post date:** [September 19, 2015, 11:06pm UTC](https://forums.unrealengine.com/t/addreferenceobject-vs-addreferencedobjects/42283/2 "2015-09-19T23:06:08Z")

</div>

Nevermind, I brainfarted. Still, the second part of my post I am unclear about

---

<div class="post-metadata">

**Author:** ![kamrann](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kamrann](https://forums.unrealengine.com/u/kamrann)\
**Post date:** [September 20, 2015, 7:51am UTC](https://forums.unrealengine.com/t/addreferenceobject-vs-addreferencedobjects/42283/3 "2015-09-20T07:51:38Z")

</div>

TMap and TSet are now, for the most part, supported as properties.

When you do override UObject::AddReferencedObjects, you don’t need to call it. It’s called by the garbage collection framework as needed.

As for the enum, no, referencing is only for UObjects.

---

<div class="post-metadata">

**Author:** ![Laphicet\_Crowe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Laphicet\_Crowe](https://forums.unrealengine.com/u/Laphicet_Crowe)\
**Post date:** [September 20, 2015, 6:30pm UTC](https://forums.unrealengine.com/t/addreferenceobject-vs-addreferencedobjects/42283/4 "2015-09-20T18:30:13Z")

</div>

Alright. I tried TMap/TSet as properties but UBT gave me a slap on the wrist and told me “no”. This was with 4.9.1

---

<div class="post-metadata">

**Author:** ![HateDread](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@HateDread](https://forums.unrealengine.com/u/HateDread)\
**Post date:** [September 21, 2015, 12:23am UTC](https://forums.unrealengine.com/t/addreferenceobject-vs-addreferencedobjects/42283/5 "2015-09-21T00:23:20Z")

</div>

> [@Schala Zeal;383263](#):
>
> Alright. I tried TMap/TSet as properties but UBT gave me a slap on the wrist and told me “no”. This was with 4.9.1

It won’t work if you try to expose them to blueprints 🙂

---

<div class="post-metadata">

**Author:** ![Laphicet\_Crowe](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Laphicet\_Crowe](https://forums.unrealengine.com/u/Laphicet_Crowe)\
**Post date:** [September 21, 2015, 7:15pm UTC](https://forums.unrealengine.com/t/addreferenceobject-vs-addreferencedobjects/42283/6 "2015-09-21T19:15:35Z")

</div>

I know that much, but even then, it said no
