# Need some explanation about collection proxies

**URL:** <https://forum.defold.com/t/need-some-explanation-about-collection-proxies/78602>\
**Category:** Questions\
**Created:** [October 26, 2024, 8:47am UTC](https://forum.defold.com/t/need-some-explanation-about-collection-proxies/78602 "2024-10-26T08:47:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sqvarek](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sqvarek/32/22354_2.png) [@sqvarek](https://forum.defold.com/u/sqvarek)\
**Post date:** [October 26, 2024, 8:47am UTC](https://forum.defold.com/t/need-some-explanation-about-collection-proxies/78602/1 "2024-10-26T08:47:55Z")

</div>

Hi there. Just started with Defold, so far it’s quite nice. Love it for the speed of execution and builds. But the topic of collection proxies seem to be a very confusing one. Just bumped into something strange myself and would very much appreciate some clarification.

So I have a loader game object with a collection proxy component and a bunch of scenes I’d like to switch between. I’m using the **collectionproxy.set\_collection** call. to set different collections on the same proxy. Then I do the **async\_load** and listen for **proxy\_loaded** message. If there’s already a collection loaded I check that and do unload, then wait for **proxy\_unloaded** , then do **async\_load**. Every time I get ok status from **collectionproxy.set\_collection** call.

 ![image](https://forum-defold-uploads.b-cdn.net/original/3X/1/4/148e61d72583e220126359954baccd6bf153b1c9.png)

But this doesn’t seem to work unless I add collection proxies with all the collection I’d like to switch to up first. I don’t have to reference them, use them or anything. They just have to be there like so:

 ![image](https://forum-defold-uploads.b-cdn.net/original/3X/0/4/047519d2c3b987ebaa0345b3507fc3ecbaf0119d.png)

If I only use one collection proxy and would like to switch the collection I don’t receive the **proxy\_loaded** when setting a collection other then the one set in the editor. Any ideas? 🙂

Also, is there a way of checking for the collection loading progress in case It might take a while and I’d like to have a progress bar or something? Looking at the specs it looks like maybe **get\_resources** / **missing\_resources** might be the way?

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [October 26, 2024, 2:24pm UTC](https://forum.defold.com/t/need-some-explanation-about-collection-proxies/78602/2 "2024-10-26T14:24:20Z")

</div>

> [@sqvarek](#):
>
> I’m using the **collectionproxy.set\_collection** call

Why? The `collectionproxy.set_collection` is what I’d call a “power user” feature for developers that download additional game content as part of a dlc of some kind and need to modify existing collection proxies.

If you need to load and unload “scenes” then create one collection proxy per collection and load and unload them. Do not bother with `set_collection`.

> **[Proxy](https://defold.com/examples/collection/proxy/)**
>
> This example shows how to use collection proxies to load and unload collections.

---

<div class="post-metadata">

**Author:** ![sqvarek](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sqvarek/32/22354_2.png) [@sqvarek](https://forum.defold.com/u/sqvarek)\
**Post date:** [October 26, 2024, 4:34pm UTC](https://forum.defold.com/t/need-some-explanation-about-collection-proxies/78602/3 "2024-10-26T16:34:12Z")

</div>

Hey, thank you for such a fast reply 🙂 If that is the intended use then that is what I’ll do.

May I also ask how to go about the loader for larger collections loaded through the proxy? I assume that such a collection is loaded into RAM on load/async\_load, right? So if it’s resource-heavy (textures and so on) then it may take a while. Also, is it doable to preload some resources? Very sorry if those are newbie questions. Tried to look around the web, but I’ve only found a feature request for something like this (5242). Are there any possibilities here?

---

<div class="post-metadata">

**Author:** ![Mathias\_Westerdahl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/mathias_westerdahl/32/228_2.png) [@Mathias\_Westerdahl](https://forum.defold.com/u/Mathias_Westerdahl)\
**Post date:** [October 27, 2024, 8:32am UTC](https://forum.defold.com/t/need-some-explanation-about-collection-proxies/78602/4 "2024-10-27T08:32:10Z")

</div>

> So if it’s resource-heavy (textures and so on) then it may take a while

I’d say, step one is to measure if it’s a problem.  
I’d recommend using load async, so that you don’t have any stalls on any loading screens.

But yes, it’s generally recommended to only put the resources you need into each collection  
(e.g. think “level1”, “level2” and so on), as opposed to loading one mega collection containing all levels.

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [October 27, 2024, 2:19pm UTC](https://forum.defold.com/t/need-some-explanation-about-collection-proxies/78602/5 "2024-10-27T14:19:56Z")

</div>

> [@sqvarek](#):
>
> Also, is it doable to preload some resources?

> [@Mathias\_Westerdahl](#):
>
> I’d recommend using load async, so that you don’t have any stalls on any loading screens.

You are not able to preload a subset of the resources used by a collection proxy, but you can ofc load all of them but not initialise the load collection objects. You can also be more granular about it and async load, then initialise all objects, and then later also enable them. See “init” and “enable”:

- [API reference (Collection proxy)](https://defold.com/ref/stable/collectionproxy/#init)
- [API reference (Collection proxy)](https://defold.com/ref/stable/collectionproxy/#enable)

---

<div class="post-metadata">

**Author:** ![sqvarek](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/sqvarek/32/22354_2.png) [@sqvarek](https://forum.defold.com/u/sqvarek)\
**Post date:** [October 31, 2024, 3:34pm UTC](https://forum.defold.com/t/need-some-explanation-about-collection-proxies/78602/6 "2024-10-31T15:34:34Z")

</div>

Great! Thank you for the answers 🙂
