How can I keep my Realtime prefabs out of the Normal/Resources folder?
Prefabs that have a realtime view in them must be kept within the Normal/Resources folder. Is there anyway to change this? I'd like to keep the prefabs organized within my directory as best suits my project.
5 Replies
Hi @beeeen. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
You don't need to keep your Realtime prefabs specifically in a "Normal/Resources" folder. The requirement is simply that they need to be in any "Resources" folder within your project so they can be loaded at runtime.
However, if you want to avoid using Resources folders altogether (which is recommended for larger projects due to performance issues), Normcore provides a way to use the Addressables system instead.
Normcore includes two interfaces that can hook into the prefab loading and instantiation pipeline:
-
IRealtimePrefabLoadDelegate
- IRealtimePrefabInstantiateDelegate
You can implement a custom prefab load delegate to use Addressables instead of Resources. Here's how you can set it up:
1. Create a script that implements IRealtimePrefabLoadDelegate
:
2. Add this component to the same GameObject as your Realtime component.
3. Set up your Addressables system and add your Realtime prefabs to it.
4. When instantiating, you'll use the asset key as the prefab name:
This approach allows you to organize your prefabs however you want in your project structure while still making them available to Normcore at runtime.
Using Addressables
By implementing this system, you can keep your prefabs organized in a way that makes sense for your project structure rather than being forced to use Resources folders.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@690217885540417680> Kapa.ai is still learning and improving, please let me know how I did by reacting below.
This is a Unity requirement. If a prefab isn’t referenced anywhere it gets stripped from builds unless it’s in a Resources folder
You can use addressables if you’d like
but why not just put a Resources folder within your other folders?
You can have multiple Resources folders and that’s how most folks organize this stuff
That's a very astute question 😂 It never occured to me
I'll just do that! Thanks @maxweisel !
sure thing