Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Can webgl do long npc dialog without running out of memory?

Discussion in 'Audio & Video' started by Michael_Swan, Sep 4, 2023.

  1. Michael_Swan

    Michael_Swan

    Joined:
    Aug 24, 2021
    Posts:
    49
    Hi,
    I have a game with lines of spoken dialogue - each audio clip isn't repeated unless they run the dialog sequence again. Each audio clip is 1 ~3 sentences.
    Is the audio freed properly in webgl, or will it eventually crash ?
    I'm just about to generate 100's of lines of voice generated dialog and be great to know it whether it will work in webgl or not. ie I can just leave a s text instead.
     
  2. SeventhString

    SeventhString

    Unity Technologies

    Joined:
    Jan 12, 2023
    Posts:
    290
    You can customize your memory management directly with
    AudioClip.LoadAudioData
    and
    AudioClip.UnloadAudioData
    if you want to have a tighter grip on how this data is handled.
     
    bugfinders and Michael_Swan like this.
  3. Michael_Swan

    Michael_Swan

    Joined:
    Aug 24, 2021
    Posts:
    49
    Oh cheers, I'm replaceing the aduioClip with a new one each new dialogue sequence. I assume that it would unload the old audio clip?
     
  4. FaiziAhmi

    FaiziAhmi

    Joined:
    Sep 14, 2023
    Posts:
    1
    Yes, I'm replacing the audio clip with a new dialogue sequence. I assume that it would unload the old audio clip?
     
    Last edited: Sep 15, 2023
  5. SeventhString

    SeventhString

    Unity Technologies

    Joined:
    Jan 12, 2023
    Posts:
    290
    Not necessarily. If you have any other objects holding references to that clip it won't be garbage collected, or become eligible to automatic unloading. Using UnloadAudioData() is the best way to explicitly and immediately unload.
     
    Michael_Swan likes this.