I have 60+ characters in a game I’m working on, I’ve created them using an internal character editor, using multiple assets/meshes - bodies, eyes, clothes, hair, etc. - combining them into create a single skinned mesh which can be controlled by a rig.
I have all the body parts and clothing in a plain asset folder. In another folder, I store all the characters as precompiled prefabs. Instead of interacting with the hierarchy directly, I created a UnityEditor interface with dropdowns and toggles to choose what the character wears and other aspects of their appearance)
With this system I can drag and drop characters into a scene, hit play and they’ll work as intended.
But what if I considered an in-game character customizer?
Or consider a very similar problem - an in-game level editor, exposing the user to the entire library of assets that make up the environment.
Currently, I rely on AssetDatabase (LoadAssetAtPath(), FindAssets(), etc.) to generate a character within the editor, obviously this won’t work in-game.
I’m very confused by Unity’s asset-bundle/resources/shared-assets system.
Should I put all of the body-parts, hairstyles and clothing into a Resources folder and replace ‘AssetDatabase’ references with ‘Resources’? I get the impression this is bad practice. Why?
Would a single AssetBundle containing all customization assets be more appropriate?
What if I created a loadable ScriptableObject asset which contained references to every single customization asset, which can at any point be Instantiated?
Is there essentially any major difference with each of these approaches?
I understand there’s a significant cost whenever loading resources on the hoof and issues with memory management.
But fundamentally I don’t understand why I can’t just say ‘Unity, load this asset now’ as I do with the AssetDatabase class in an editor script. I know the compiled application uses a different file-structure, but surely the asset can be loaded into memory besides using AssetBundles or Resources?
My understanding of AssetBundles and Resources is lacking at best, as I’ve tried to avoid using them until now.
I hope this post fully exposes the true depth of my ignorance. All I want in cases like this is to be told I’m wrong about something.
I can’t tell you how difficult I’ve found it to get clear answers (or any answers at all) when it comes to issues with Unity. While I have a long background in game development and have been using Unity for over a year now, I’ve had so much trouble getting to grips with it. There’s just something about Unity’s API that leads me down countless blind-alleys and chains of misapprehensions.
I relate it to how in a sudoku, one wrong number can lead to a snowball effect of errors.
It’s very frustrating.
Sorry to go on like this…
Any help or advice would be greatly appreciated.