Unable to find assets in resources sub directories

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
jlhacode
Posts: 77
Joined: Fri Jul 03, 2020 6:23 am

Unable to find assets in resources sub directories

Post by jlhacode »

Hi,

I'm using a 'VoiceOverFile' field in my DialogueEntries as tags in order to play audio at the beginning of conversations.

I'm running into two problems:

1. The asset won't be found if it's located in a sub-folder inside of the Resources folder.

2. The asset won't be found if it contains an accent (e.g. 'ç')
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Unable to find assets in resources sub directories

Post by Tony Li »

Hi,
jlhacode wrote: Wed Sep 16, 2020 8:51 pm1. The asset won't be found if it's located in a sub-folder inside of the Resources folder.
If you're using articy, don't put your audio files in subfolders. Instead of this:

Assets/Resources/NPC1/audio files...
Assets/Resources/NPC2/audio files...
Assets/Resources/NPC2/audio files...

do this:

Assets/NPC1/Resources/audio files...
Assets/NPC2/Resources/audio files...
Assets/NPC3/Resources/audio files...

If you must use the first folder structure (Assets/Resources/NPC1/audio files...), then you can include the NPC name in the sequencer command, such as:

Code: Select all

AudioWait([var=Conversant]/entrytag)
jlhacode wrote: Wed Sep 16, 2020 8:51 pm2. The asset won't be found if it contains an accent (e.g. 'ç')
That may be a limitation of your file system. The Dialogue System doesn't care in this case if you use accents or not, but Unity and your file system may care.
jlhacode
Posts: 77
Joined: Fri Jul 03, 2020 6:23 am

Re: Unable to find assets in resources sub directories

Post by jlhacode »

Hi Tony,

Hmm. I'm not using Articy... oh well.

Anways, you pointed out that it could be related to my particular filesystem, but I didn't know enough about them... so I decided to do a little bit of research.

I found out that cramming things in the Resources folder isn't exactly best practice, and that I should be utilizing addressables to hold my audio files. I also found out that you mention Addressables in your 2.2.10 update!

I was wondering if there was any documentation on how to handle Addressables in Dialogue System with the "VoiceOverFile" entry tag, or if you could point me to the right spot. I see the "How to Use AssetBundles" section in the documentation for Cutscene Sequences, but that's about it. Is there a specific directory (for the Addressable address) that I should house my audio clips in, or should the address be the name of the file?
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Unable to find assets in resources sub directories

Post by Tony Li »

Hi,

Sorry for the confusion. VoiceOverFile happens to be the custom field name used by the Dialogue System's articy:draft voiceover plugin integration, so I assumed you were using articy. No worries!

Addressables are a very good way to go.

1. Enable the Addressables package in Unity's Package Manager window. (Menu item Window > Package Manager.)

2. Open the welcome window. (Menu item Tools > Pixel Crushers > Dialogue System > Welcome Window). Tick USE_ADDRESSABLES.

3. Put your audio files anywhere in your project. You no longer need a Resources folder for them.

4. Tick each audio file's Addressable checkbox and set its addressable name. By default, it's the filename (e.g., "Private_Hart_1_1"). Typically this corresponds to the dialogue entry node's entrytag.

5. Set the Dialogue Manager's Default Sequence and/or each node's Sequence to something like:

Code: Select all

AudioWait(entrytag)
The AudioWait() sequencer command will automatically find your addressable by its addressable name and play it. It will also automatically unload it from memory when done. The other sequencer commands work similarly.

If the Dialogue System doesn't find the asset as an addressable, it will check any assetbundles that you've registered, and, failing that, it will check Resources.
jlhacode
Posts: 77
Joined: Fri Jul 03, 2020 6:23 am

Re: Unable to find assets in resources sub directories

Post by jlhacode »

Your post definitely put me on the right track, but I'm having just one more hang-up.

My default addressable keys get generated with the directory prepended to the file name, with the file format appended at the end.

e.g. "loud_noise.ogg" gets turned into "Assets/Audio/loud_noise.ogg", which won’t work. It needs to be formatted to "loud_noise" to be automatically picked up.
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Unable to find assets in resources sub directories

Post by Tony Li »

It's a bit of a headache, but just delete the prepended directory part.

Here's a silly hack which may or may not work depending on your Unity version: Put the audio files in a Resources folder. Then tick their Addressables checkboxes. Unity will offer to move them out of the Resources folder. In doing so, it will also set each file's key to its filename without prepending the directory. Then you can delete the empty Resources folder.
jlhacode
Posts: 77
Joined: Fri Jul 03, 2020 6:23 am

Re: Unable to find assets in resources sub directories

Post by jlhacode »

Awesome, that got everything working. Thanks Tony!
Last edited by jlhacode on Fri Sep 18, 2020 3:11 pm, edited 2 times in total.
User avatar
Tony Li
Posts: 22054
Joined: Thu Jul 18, 2013 1:27 pm

Re: Unable to find assets in resources sub directories

Post by Tony Li »

Glad to help!

The recording wasn't quite in focus enough to see, but I'm guessing you're talking about that Resources hack I mentioned. :-)
Post Reply