Unity - Loading Assets / Resources during run-time for a highly customizable game

by hedgehog90   Last Updated November 14, 2017 15:13 PM

I haven't had to think too much about this problem too much until now.

I am in the middle of creating a character customization system for my game.

There are 60+ characters in the game, I have created them using an internal character customizer, using multiple assets/meshes - bodies, eyes, clothes, hair, etc. - combining them into create a single mesh which can be controlled by a rig.

Currently I have all the body parts and clothing in one folder, labelled in such a way that with a bit of simple logic, they can be assigned to certain parts of a character's body.

In another folder, I have all the Character prefabs - GameObjects with a special Character component, which allow me to configure each character using the editor's inspector. So instead of interacting with the hierarchy directly, I use dropdowns in the inspector 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 all character's appearances as dynamic (suppose they wear different clothing depending on time of day, different accessories, etc.), then it becomes too variable to consider pre-compiling each character.

Or to really accentuate the problem - what if I consider an in-game character customizer? Or even in-game scene editor? Where objects like chairs, tables and walls have to be loaded individually during run-time.

Currently, I rely on AssetDatabase (LoadAssetAtPath(), FindAssets(), etc.) to generate a character within the editor, obviously this won't work in-game.

I am very confused by Unity's whole asset-bundle/resource pipeline. Should I put all of the body-parts, hairstyles and clothing into a Resources folder and replace 'AssetDatabase' references with 'Resources'? From looking online, I get the impression this is bad practice. Why?

Do I put every single one of these assets into a single AssetBundle? Is there any difference between a Resources folder an AssetBundle containing the same objects?

I understand this will create an overhead whenever a character needs to be created and initialized, but I don't see any other way.

I'm sure my understanding of AssetBundles and Resources is muddled at best. Possibly at the most basic level - 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 asset doesn't resemble the same file-mapping as my project folder, but surely it can still be got at.

Any suggestions on the matter would be really appreciated.

I hope the confusion I've expressed fully illustrates the depth of my ignorance. While I've been using Unity for over a year now, I've had so much trouble getting familiar with it, yet I'm usually very adaptive to new software, APIs or coding practices. There's just something about Unity that causes so many misunderstandings and misapprehensions. We don't see eye to eye on anything it seems.



Related Questions