• "Auto racing began 5 minutes after the second car was built." - Henry Ford
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Dear Guest. Follow RaceDepartment on Twitter, Facebook, Instagram, Twitch, Steam and YouTube.

Tutorial: How to import custom sounds to in-game

Discussion in 'My Summer Car' started by ajanhallinta, Nov 25, 2016.

  1. ajanhallinta

    ajanhallinta

    Messages:
    46
    Ratings:
    +14
    Modding is not officially supported. Take backups of game and save files before modding. Do at your own risk.

    Updated:
    You can use C# and Mod Loader to load AudioClip using Unity's WWW -class. Here is an example taken from my Recorder Flute -mod:

    Code:
    // Load .wav file using WWW -class.
    WWW RecorderSound = new WWW("file:///" + @Path.Combine(ModLoader.GetModAssetsFolder(this), "g5.wav"));
    while (!RecorderSound.isDone) { }; // Wait sound to be loaded.
    
    // Add clip to recorder flute.
    RecorderPivot.GetComponent<AudioSource>().clip = RecorderSound.GetAudioClip(false);

    To replace existing sounds, you need to find the according AudioSource that holds the clip you want to replace. There is many way to acquire it; one approach could be scanning through all AudioSources with foreach -loop and check if the clip name of AudioSource matches to one you are replacing.

    Pseudo-Example:

    Code:
            
    foreach(AudioSource audio in GameObject.FindObjectsOfType<AudioSource>())
            {
                if(audio.clip.name == "ClipToReplace")
                {
                    // Load .wav file using WWW -class.
                    WWW NewSound = new WWW("file:///" + @Path.Combine(ModLoader.GetModAssetsFolder(this), "g5.wav"));
                    while (!NewSound.isDone) { }; // Wait sound to be loaded.
    
                    audio.clip = NewSound.GetAudioClip(true); // Change clip to AudioSource
                }
            }

    OUTDATED METHOD:

    Needed programs:
    - Unity
    - Unity Asset Bundle Extractor
    - Soundfile (.wav)
    - Notepad


    Use Unity Asset Bundle Extractor to find an AudioClip to replace from mysummercar_Data/sharedassets2.assets. Rename your .wav file with that name.

    1.) Open Unity and make new project.
    2.) Copy your .wav file to your projects Assets/ -folder.
    3.) Add a new GameObject to scene and add Audio Source component to it.
    4.) Drag & Drop your .wav file to AudioSources AudioClip -field.
    5.) In File -> Build Settings, add your scene to build and click Build to build your project somewhere.
    6.) Find your buildedprojectname_Data/ and files "sharedassets0" and "sharedassets0.assets.resS" (it name may be sharedassets0.resource too) .
    7.) Rename "sharedassets0.assets.resS" file anything you want (for ex. "hayosikosounds.resource") and copy it to mysummercar_Data/ -folder
    8.) Use Unity Assets Bundle Extractor to Export your AudioClip to 'Dump' from buildedprojectname_Data/sharedassets0.assets file.
    9.) Open the Dump file in Notepad and find following line: 1 string m_Source = "sharedassets0.assets.resS" and change that to point your resource file ("hayosikosounds.resource").
    10.) In Unity Assets Bundle Extractor, open mysummercar_Data\sharedassets2.assets file and find the original AudioClip
    11.) Click "Import Dump" and select file you previously extracted
    12.) Use File -> Mod Maker -> Create standalone .exe installer to create installer and save it to MSC root folder
    13.) Run installer.

    Let me know if there are succes or problems with this, or is this readable at all...
     
    Last edited: Nov 8, 2017
  2. SegaDevSrbija

    SegaDevSrbija

    Messages:
    9
    Ratings:
    +1
    Amazing,looking for this tutorial for like 2 or 3 months :D
    Amazing job
    Thank you very much man :)
     
  3. CoexistanceIsKey

    CoexistanceIsKey

    Messages:
    40
    Ratings:
    +2
    Hey bud, I'm stumped at number 12. What program are we supposed to use? Mod Loader?
     
  4. SegaDevSrbija

    SegaDevSrbija

    Messages:
    9
    Ratings:
    +1
    You're supposed to use UABE :p
     
  5. CoexistanceIsKey

    CoexistanceIsKey

    Messages:
    40
    Ratings:
    +2
    But there's literally no option for "File - Mod maker"
     
  6. SegaDevSrbija

    SegaDevSrbija

    Messages:
    9
    Ratings:
    +1
    You dont need to make mod i think so,just import and save and thats it
     
  7. CoexistanceIsKey

    CoexistanceIsKey

    Messages:
    40
    Ratings:
    +2
    Well when I try to save it, it just says cannot open the file for writing
     
  8. SwishyST

    SwishyST

    Messages:
    1
    Ratings:
    +0
    Hello, I'm having an issue with step 8. When I import my sharedassets0.assets file from the project UABE will not respond and eventually crash. Is there any other steps I'm missing when setting up the unity project? Thanks!

    EDIT: I figured it out, I was using a very old version of UABE for some reason, got the newest version and all worked well!
     
    Last edited: Jun 11, 2017
    • Disagree Disagree x 1
  9. Unlucky person

    Unlucky person
    Banned

    Messages:
    2
    Ratings:
    +0
    Hi man how can i launch mods on cracked version of my summer car
     
  10. CoexistanceIsKey

    CoexistanceIsKey

    Messages:
    40
    Ratings:
    +2
    Buy it lol
     
  11. CoexistanceIsKey

    CoexistanceIsKey

    Messages:
    40
    Ratings:
    +2
    When I try to launch the installer created from UABE, it just crashes.
     
  12. Mazen91

    Mazen91

    Messages:
    17
    Ratings:
    +4
    Not sure if it's fitting though, but I guess so...
    So how would I go about exporting an AudioSource to use in a mod I'm writing using MSCLoader?
     
  13. ajanhallinta

    ajanhallinta

    Messages:
    46
    Ratings:
    +14
    I updated first post to show example, how to load new samples using C# and Mod Loader. If you want to export .wav:s from the game itself, i suggest you to use UABE as it can export sound files to .wav.

    However if you want to export sounds with Mod Loader -script while in-game, i'm not entirely sure how to do that, but maybe you can try something like this: https://gist.github.com/darktable/2317063
     
    • Like Like x 1
  14. Mazen91

    Mazen91

    Messages:
    17
    Ratings:
    +4
    Thank you! Your update is exactly what I was looking for.
    I'll give it a try as soon as I get home.
     
  15. Doctor (WTA)

    Doctor (WTA)

    Messages:
    1
    Ratings:
    +0
    I'm struggling at number 8. When I try to Export Dump, it says:"The file format is empty!"
    Latest version of UABE. Please help!

    Edit:
    Don't worry, I've figured out that I've should to Export Dump from SharedAssets.assets:)
     
    Last edited: Nov 20, 2017 at 16:48