DEV Community

woodendoors7
woodendoors7

Posted on • Updated on • Originally published at nuclearoption.wiki

How to get custom sounds for Unity Games?

Have you ever wanted custom sounds in any Unity Game? You're in luck, let me show you how.

Part 1: Download all needed parts


You will need these programs:

  • Unity 2022.3.12f1 Download it here
    • You'll need unity to create your own resource files, which you can then use to replace the current sounds in your unity game.
  • UABEAvalonia Download it here
    • You'll need UABEA to edit asset files of your game, or any other unity game. This allows you to link a given asset to a different resource.

To install Unity, follow the download link, then simply press “Unity Editor Windows”, or whatever operating system you are using. After downloading, unity will install Unity Hub, which will require you to create an account, and then download the actual unity editor. After all this is done, Unity is installed.

To install UABEA, follow the download link, scroll a bit down, and click on a file that says uabea-windows.zip or anything similar. You will need a program like 7-zip or WinRAR to extract this zip. Make a new folder on your desktop, name it however you want, and then drag all the files from inside the zip into the folder.

Part 2: Scope out your files using UABEA


Open your game's game files

Open Steam. Click “Library” on the toolbar, and then search for your game (or any other unit game) on the left panel. Right click it, and press “Browse Local Files”. When a file explorer window opens, open the folder 📂Your_data. Then, right-click the address bar at the top of file explorer, and click “Copy address as text”.

tutorial pic showing how to open local game files in Steam

Start UABEA and open the asset file

  1. Go into the folder with the extracted UABEA files from the previous part. Double-click the file named UABEAvalonia.exe, which should have a white and pink icon.
  2. Click on “File”, and open. Now, click on the empty part of the address bar, and paste in the path which you copied in the previous step, then press enter.
  3. Search for a 📁resources.assets file. Double click it.

A new window should be opened, which lists all the resources in the game.

    tutorial showing how to open an assets file in UABEA

Look for files of interest.

  1. Click on the “Type” column, which will sort all the files by type. This will help you find AudioClips;
  2. Now, find them by names! You need to do some guessing, for example, missile warning is of course going to be called missileWarning, but some names might be less intuitive.

  3. If you wanna quickly preview the assets, you can use AssetRipper, which allows you to view them live and export them, but it cannot use assetripper to modify resources.
    <li>Check if they're the files you're intending to replace, and note their names. </li>
    

Part 3: Make your replacement assets in Unity


tutorial showing how to create a new project in Unity

  1. Open Unity Hub. Go into Projects and press “New Project”. Make sure to select 3D (Core). Name it whatever, and select a unity cloud organization. Feel free to uncheck Connect to Unity Cloud, so your game isn't backed up to the cloud.
  2. Once your editor opens, you might see several panels. There should be a Project/Assets panel at the bottom.
  3. Drag your audio files into the bottom file panel. Make sure to name them exactly as they are named in the asset files, so you can overwrite them.
  4. From the bottom panel, drag the files to your scene.
  5. After this is done, save and compile your game. Go into File > Build Settings, Select Windows as the target platform, and press “Build”. A folder picker window will open, create a new folder and name it anything you want, like builds, and select that folder.

tutorial showing how to import audio files into unity and drag them onto the scene

The game and its assets will now build into that folder.

Part 4: Create dumps


Look in the folder you just created, and compiled into. There should be a gameName_data folder. Open it. Your files of interest are 📂sharedassets0.assets, and 📂shareassets0.resource. The .assets file stores the references to resources, the .resource file stores the actual resources (audio files).

tutorial showing how to export dumps of assets in UABEA

  1. Using UABEA, open the 📂sharedassets0.assets file. Find the resources you want to export, and on the right side, press “Export Dump”. You can choose whether to export the dump as .json or as .txt
  2. Since there is already a sharedassets0.resource file in your game's data, rename it to anything you want, like ResourcePack.resource or just like mash your keyboard.
  3. Open the dumps in a text editor. You will need to edit the m_Source field to have the name of your .resource file, which you just renamed in the last step.

tutorial showing how to modify an exported UABEA dump to point to the correct resource file

Part 5: Modify your game's asset files.


Now you'll need to modify your game's 📂resources.assets file, so the resources point to your custom resources, in your custom .resource file.

tutorial showing how to copy my custom resource file and how to create a backup of the asset file

  1. Drag your custom .resource file into 📂YourGame_data
  2. Create a backup of your resources.assets file. Copy and paste it to make a copy, in case you mess stuff up (you will).
  3. Open the 📂resources.assets file in UABEA again. Find the assets you need to replace. Press on it, press “Import Dump”, choose whether you are importing .json or .txt, and import.
  4. Make sure you have edited the asset names and asset source before importing them into UABEA, as using “Edit Data” in the program likes to mess up the assets.
  5. Save the assets file by doing File > Save.

And there you have it! A custom sound inside of your Unity Game!

I've also made a tutorial specific to Nuclear Option!

Top comments (0)