[ Coding ] AssetBundle loader issue ( multiple persons )

hazmhox

Moderator
Featured Contributor
Messages
1,515
Reactions
7,330
Points
173
I was trying VAMMoan on a single character since the beginning of the dev. Yesterday I tried to add it to two characters, and I run into an issue.
When the scene loads, or I try to swap to an assetbundle that is already loaded by the other character, I get an error message saying that the assetbundle is not valid.

Code:
Error during attempt to load assetbundle Custom/Scripts/VAMMoan/audio/Isabella/voice.voicebundle. Not valid

So I traced my loading system :

Girl1 - Grace
Girl1 - Starting load request Custom/Scripts/VAMMoan/audio/Grace/voice.voicebundle
Girl2 - Isabella
Girl2 - Starting load request Custom/Scripts/VAMMoan/audio/Isabella/voice.voicebundle
Girl1 - Load request completed Custom/Scripts/VAMMoan/audio/Grace/voice.voicebundle
Error during attempt to load assetbundle Custom/Scripts/VAMMoan/audio/Isabella/voice.voicebundle. Not valid


I tried to investigate and check a few plugins here and there. MacGruber as somewhat the same thing in Life, so as I did in my plugin I tried to trace the way stuffs are loaded like mine :

Loading startedGirl1
Loading startedGirl2
Loading endedGirl1
Loading endedGirl2

I know that the assetbundle loader locks the file. But since I'm using two different bundles in my case, that seems strange. Also, in the case of Life, the assetbundle is the same, and the problem doesn't happen... so I think I'm missing something here.

Is there some kind of parameters to send to the assetbundle loader to allow loading of multiple bundles ? What could produce that especially on two different files. Especially since the assetbundle loads perfectly when there's only one character.

The logic behind the loading system is simple :

C#:
            void LoadAudio()
            {
                try
                {
                    logDebug("Starting load request " + voicePath + "/" + this.voiceBundleName);
                    // Loading the bundle for the current selected voice
                    Request request = new AssetLoader.AssetBundleFromFileRequest {path = voicePath + "/" + this.voiceBundleName, callback = OnVoiceBundleLoaded};
                    AssetLoader.QueueLoadAssetBundleFromFile(request);
                    
                    // Loading the shared bundle used by all voices
                    Request requestShared = new AssetLoader.AssetBundleFromFileRequest {path = rootPath + "/voice-shared.voicebundle", callback = OnVoiceBundleSharedLoaded};
                    AssetLoader.QueueLoadAssetBundleFromFile(requestShared);
                }
                catch(Exception e)
                {
                    Debug.LogWarning(e);
                }
            }

            private void OnVoiceBundleLoaded(Request aRequest) {

                voiceBundleRequest = aRequest;
                List<string> audioPaths = GetAudioPaths();
                foreach( string adPath in audioPaths ) {
                    AudioClip ac = voiceBundleRequest.assetBundle.LoadAsset<AudioClip>(adPath);
                    if( ac == null ) {
                        SuperController.LogError("VAMMoan : Voice sample not found (" + adPath + ").");
                    }
                    audioClips.Add(ac);
                }
                
                logDebug("Load request completed " + voicePath + "/" + this.voiceBundleName);
            }

            private void OnVoiceBundleSharedLoaded(Request aRequest) {

                voiceSharedBundleRequest = aRequest;
                List<string> sharedAudioPaths = GetSharedAudioPaths();
                foreach( string sadPath in sharedAudioPaths ) {
                    AudioClip ac = voiceSharedBundleRequest.assetBundle.LoadAsset<AudioClip>(sadPath);
                    if( ac == null ) {
                        SuperController.LogError("VAMMoan : Shared voice sample not found (" + sadPath + ").");
                    }
                    sharedAudioClips.Add(ac);
                }
            }

HALP ! :]
 
There is no "file lock". However, if I remember correctly there is a hashmap ("Dictionary" for C#ers) internally in VaM that keeps track of the AssetBundles. That thing tracks by filename, not the full path. Therefore, my Life plugin works because the AssetBundle is actually identical. In your case you have two different bundles with the same name. People reported similar problems to me with scenes that use different versions of the Life plugin, but in that case the obvious solution is to not use different versions of the same plugin ;)

Also note that you might want to call AssetLoader.DoneWithAssetBundleFromFile(filename) when you don't need any of the content anymore. For example call it in OnDestroy().
 
Thank you for taking a bit of time to look at that MacGruber : )
Yup ! This exactly what I've done, the bundle is properly unloaded with the "Done" method.

C#:
        // Main class
        void OnDestroy() {
            // Triggers
            vaTrig.gameObject.GetComponent<SexTriggerCollide>().OnCollide -= VaTrigObserver;
            Destroy( vaTrig.gameObject.AddComponent<SexTriggerCollide>() );

            // Sounds
            if (voice != null)
            {
                voice.Unload();
            }
        }

        // Voice class
        void UnloadAudio()
        {
            // Selected voice bundle unload
            AssetLoader.DoneWithAssetBundleFromFile(voicePath + "/" + this.voiceBundleName);

            // Shared voice bundle unload
            AssetLoader.DoneWithAssetBundleFromFile(rootPath + "/voice-shared.voicebundle");

            // Clearing lists
            audioClips.Clear();
            sharedAudioClips.Clear();
            lastMoanList.Clear();
            lastKissList.Clear();
            lastBjList.Clear();
        }

And this is funny that you say that. The first thing I tried when I had the bug, was to rename the files voice.voicebundle to something unique isabella-voice.voicebundle

It was still the same result. But since I've refactored a bit of code, I'm gonna try that again. this not bad to avoid having the same filename tho. I'll keep you posted.

Also you say it is not locked, but as soon as the plugin is loaded, the file cannot be deleted (in a windows browser for instance), so maybe it is lock for modification / deletion but still readable. But it has some kind of lock... or maybe Windows is doing that ?
 
@hazmhox As per our earlier conversation on Discord....me saying I don't have time....that has not changed. However, with the info I got from you on Discord it would have taking an hour at least to get VaMMoan downloaded and the issue reproduced, than actually finding your loading code in that, etc. However, HERE you collected all the needed info in one neat post and I could write an answer in like 5 minutes. THAT is how you get help ;)
 
Nope. Same error :'(

Set3 Girl1 - Grace
Starting load request Custom/Scripts/VAMMoan/audio/Grace/voice-grace.voicebundle
Set3 Girl2 - Isabella
Starting load request Custom/Scripts/VAMMoan/audio/Isabella/voice-isabella.voicebundle
Load request completed Custom/Scripts/VAMMoan/audio/Grace/voice-grace.voicebundle
!> Error during attempt to load assetbundle Custom/Scripts/VAMMoan/audio/Isabella/voice-isabella.voicebundle. Not valid
 
@hazmhox As per our earlier conversation on Discord....me saying I don't have time....that has not changed. However, with the info I got from you on Discord it would have taking an hour at least to get VaMMoan downloaded and the issue reproduced, than actually finding your loading code in that, etc. However, HERE you collected all the needed info in one neat post and I could write an answer in like 5 minutes. THAT is how you get help ;)

Indeed. Thank you very much anyway! That's really sweet of you.
 
OK !

Another piece to the puzzle : I created a new scene, two female characters. Plugin loaded on each character, but using the same voice. Not a different one.
This time it is working. No error.

I don't understand Oo
 
So. Still no workaround.

But I made a test to be sure that it wasn't only me :

- I created a temporary var with your audio bundle from life.
- Created a scene with two girls, loaded Life on each
-> Everything works fine
- Then, choosed one of the girls, selected the audio bundle in my temporary var
-> the script isn't able to load the bundle and trigger the same exact error as I have in my case

The audio bundle was named differently of course : MacGruber_Breathing2.audiobundle

So, I'm not gonna fight and spend days on a thing that is just for an hypothetic person in the future who will maybe, create a new voice for the plugin... which, I'm pretty sure will never happen. And if it happens... maybe at this moment, I'll stalk meshed to understand what the problem is.

I'm gonna rewrite the code and pack all the voice assets in a single bundle.

Anyway, just like me... in the case of Life, at the moment, if someone was trying to create a new bundle, it wouldn't work if the scene was meant to have more than one character with the script on them and obviously with a different bundle loaded for each.

Thank you again for the time you took to checkout the thread.
 
Hi! Just had an idea during breakfast....maybe it's not the filename but rather the asset GUID inside the package. Just renaming the bundle would not change the GUID inside the bundle....same GUID means for Unity its literally the same asset. So it might work if your bundles are actually containing different files.
 
Hi! Just had an idea during breakfast....maybe it's not the filename but rather the asset GUID inside the package. Just renaming the bundle would not change the GUID inside the bundle....same GUID means for Unity its literally the same asset. So it might work if your bundles are actually containing different files.

I love the breakfast ideas ! I got some sometimes :p
I thought about that, and you may be right in the case of my repro in the bugs forum. But my original code for VAMMoan was based on three different bundles created for each character in Unity. Different audio files, different bundles, and the result was the exact same :/

(sorry to ruin your breakfast idea ! haha.)
 
Hey Leute, ich habe ein Problem, das mich wirklich beschäftigt. Ich mache es seit einer Woche und mache und probiere Tutorials aus und mache es genau so, wie es jedes Mal angezeigt wird, wenn ich das Assets-Bundle lade, obwohl es die Datei enthält ist ständig dies wird angezeigt -> Fehler beim Versuch, das Asset-Bundle zu laden, ungültig:vorsichtig:
 
Hey Leute, ich habe ein Problem, das mich wirklich beschäftigt. Ich mache es seit einer Woche und mache und probiere Tutorials aus und mache es genau so, wie es jedes Mal angezeigt wird, wenn ich das Assets-Bundle lade, obwohl es die Datei enthält ist ständig dies wird angezeigt -> Fehler beim Versuch, das Asset-Bundle zu laden, ungültig:vorsichtig:
Bitte hab keine Angst einen neuen Thread für deine Frage zu erstellen. Dein Problem hat wahrscheinlich nichts mit dem hier im Thread diskutieren Thema zu tun, da geht es um mehrere Plugin-Instanzen (VAMMoan bzw. Life) zu tun die versuchen AssetBundles zu laden. Dein Problem klingt eher nach einem kaputten AssetBundle. Bitte erstelle einen neuen Thread, idealerweise mit einer besseren Beschreibung was du versuchst, welches AssetBundle und ein Screenshot der Fehlermeldung. Und natürlich verstehen 95% der Nutzer hier kein Deutsch, also English zu schreiben würde die Wahrscheinlichkeit erhöhen das die jemand helfen kann. Im Zweifel http://translate.google.com/ benutzen.

English: Please have no fear to open a new thread for your question. Your problem seems unrelated to the topic discussed in this thread, which is about multiple plugin instances (VaMMoan or Life) that try to load AssetBundles. You problem sounds more like having a broken AssetBundle. Please create new thread, ideally with a better description of what you are trying, which AssetBundle you are using as well as a screenshot of the error message. And of course 95% of the users here do not understand German, so writing English should increase the likelihood of someone being able to help you. When in doubt, use http://translate.google.com/.
 
⅘I totally forgot sorry it is about if I made a house in 3D from Unity and convert it to assetsbundle and I want to load it into virt a mate, it constantly says that this is invalid although I have copied everything according to the tutorial others It loads assetsbundle perfectly because there are no problems, only I made the error code in my first comment at the bottom
 
Back
Top Bottom