Sorry for the length....iIf anyone is searching and finds this, I hope it helps. I know this post is a little old but I've been struggling with creating a new sound for a18.3. Followed all the tutorials I can find, tried many things. Finally found what worked (for me). I believe, from all my testing, that a *very specific* version of Unity is needed, or at least a very narrow range of Unity versions will work. It also appears that you need to be using Windows.
I'm a complete Unity noob, so please be gentle if I've misstated the obvious
So, for a18.3...
Use a Windows OS (I'm using Windows 10). I've tried the Linux versions (On Ubuntu 18.04 LTS) and have had issues with it. it may work somehow/some way but I'm so tired of experimenting. I had all sorts of issues like buttons not working the same way like windows does (drop downs missing, etc). And I suspect that there may be other issues like when exporting files (because the base OS is not Windows). Maybe its' just my install(s) though. If I try on Unix again I may post how, but I've also had much difficulty getting the UABE working on Ubuntu (it works, once again some options not working the same as Windows) and the new DMT mod maker I cant get working on Ubuntu.
Get a version of Unity installed that's compatible with a18.3 (or whatever version you want to mod for. I believe every game version needs a specific version of Unity (ots documented somewhere on these forums) and for 18.3 its not just any Unity version "2019.x.x" but specifically 2019.1.x and maybe "2019.1.14f1"
- Download Unity Hub from https://unity3d.com/get-unity/download . The Unity Hub is like a "manager" of Unity installs and projects.
- Open Unity Hub, click "installs"
- Click "Add", then click the "Download archive" link
- Find for a18.3 of 7D2D, find version "2019.1.14f1" and click the "Unity Hub" button, which will cause Unity Hub to download that version. Wait forever for it to install.
Note: For the next step I'm not sure if you need to open a "new" project in order to set the Unity "Projects folder" for all projects OR if you can skip setting a default project folder. There's probably several ways to add a project but I'm not sure what is "best". just keep going forward
Now go get the/an example project (this may not be completely necessary but it helps to have anyway, and it works)
- Go to https://github.com/7D2D/Templates-and-Utilities
- Extract the TutorialProjectTemplate2019.1.zip folder <- Note, this repo does not have any specific releases to choose so its possible it will be updated in the future and the zipped tutorial will change/be updated. Since its literally named 2019.1 this is unlikely. The last commit date on the repo I'm using is: Dec 11, 2019.
- From within that folder, copy the XythTutorialsV2 into your Unity Projects Folder. If you don't have a project folder, make one, or it's possible you could just remember where this project folder is.
- Go back to Unity Hub, on the main "page" click "Add" and select the XythTutorialsV2 folder.
- Now in the Hub you will see an item for the Project named "XythTutorialsV2" and *hopefully* the Hub will auto add/discover the Version of Unity to it. If it does not then you have to choose a version of Unity to open it with from the "Unity Version" drop down/column
- Click on the Project to Open it. If the Unity you downloaded and the version of Unity used in the project differ, the Hub will either ask you to "upgrade your project" or "downgrade your project, but it may cause issues". As of this dates posting, I did not get such a pop up with the Project version and Unity version I chose. I did choose other unity versions (as I was testing) and every option I chose caused the sound I made for the 18.2 game to not work.
Now have Unity open to the tutorial project. The tutorial project has a few special things (I have read) in it that you do not get with an empty project:
1. It has a working "flag" demo. For sounds we do not need it
2. It has had all the "tags" from the game added to it. For sounds we don't need to concern ourselves with picking tags for things.
3. It has a c# file in it called "MultiPlatformExportAssetBundle.cs". We need this (badly) as you cannot export .unity3d files without it. Vanilla Unity will not export .unity3d files (maybe someone can explain why this is.). Also, for your notes, there appears to be another c# file called ExportAssetBundles.cs in the https://github.com/7D2D/Templates-and-Utilities project that other people reference in the forums BUT I believe this is an older version and the "MultiPlatformExportAssetBundle.cs" is the proper one to use.
Note: I'm going to cover just exporting 1 sound, but you can do multiple sounds (watch the video tutorials) into a single .unity3d file.
Note: I've seen references to 3 types of sound formats working: .wav, .mp3, and .ogg. For this I'm only going to use .wav files as the UABE extracts these by default.
Now "Import" the sound file unto Unity via drag + drop. Lets say our sound file is named "newsound.wav" and it's on the Windows desktop. Just "drag" the sound file from the desktop into Unity in the "Assets" panel (located under the "Projects" tab). You can drag it onto the Assets folder or into the Assets panel.
At this point: There appear to be 2 differing philosophies in how to export sound(s) into a .unity3d format and use them in the game. Some people claim one or the other works, likely they both work in some contexts.
Export the sound into a .unity3d file:
Method 1: Just export the sound. In Unity, right click on the "newsound.wav" file and choose "Build Multi-Platform AssetBundle From Selection". When the pop up appears, name the file "MyNewSound.unity3d" and save it. Note: The "Build Multi-Platform AssetBundle From Selection" ONLY appears because you have the "MultiPlatformExportAssetBundle.cs" file provided with the tutorial in the Assets folder.
Method 2: Create GameObjects and attach the sound file to it. NOTE: THIS METHOD DID NOT WORK FOR ME but it seems it works for others. I have no idea why. I'm documenting it here just to put both methods side by side.
- In Unity, go to the "Hierachy" tab, then into the "XythTutorials" area and right click on the empty space in the window. A pop up selector will appear. Choose "Create Empty".
- A new item called "GameObject" will be created (a little cube icon). Right click and Rename this object "newsound2". Note: You can name this anything you want, but I would stick to no spaces. I'm specifically not naming this "newsound" so the differences between Method 1 and 2 can be shown.
Note: In the forums this is referenced as the "parent".
- Right click on the "newsound" object. A pop up selector will appear. Choose "Create Empty". A new "GameObject" will appear under the "newsound2" object. Note: In the forums this is referenced as the "child".
- Select "newsound.wav" and drag it onto the "GameObject" icon you just created.
- Drag the "newsound2" game object into the "Assets" folder where your "newsound.wav" is. It will make a new cube icon.
- In Unity, right click on the "newsound2" cube icon and choose "Build Multi-Platform AssetBundle From Selection". When the pop up appears, name the file "MyNewSound.unity3d" and save it.
Add you new sound to a custom modlet.. You should now have a "MyNewSound.unity3d" file created. This is beyond this tutorial, but read the forums and make (or copy) a modlet that uses a custom sound file. I would suggest https://github.com/Khelldon/7d2dModlets/tree/master/Khelldon-GetHorny as it modifies the horns on the vehicles in the game and all you have to do is modify it to add your custom sound for a vehicle in the game then play the horn on a vehicle to hear your custom sound. Ultimately in the modlet you will need:
- A folder in the modlet called "Resources" where you will place your MyNewSound.unity3d" file
- To have something in the modlet that modifies the "sounds.xml" file to add the sound to a SoundDataNode, and then reference that SoundDataNode's "name" to play the sound. I'm choosing here to document what a new SoundDataNode may look like just to show how Method1 and 2 differ in referencing the new sound file:
EXAMPLE SoundDataNode in sounds.xml:
<Noise ID="1" range="1" volume="7" time="3" muffled_when_crouched="0.5"/>
So: The I'm not sure if all the sound properties above are needed, but the new sound is added via this line:
When using Method 1, the line looks like:
When using Method 2, the line looks like:
Notice the slight difference:
- The actual file name of the sound file "newsound.wav" is used in Method 1 to reference the sound, except the file extension is not used. This means how you name the original sound file matters in how you ultimately reference it in the game.
- The actual file name of the sound file "newsound.wav" is NOT used in Method 2 to reference the sound, its actually the name of the parent GameObject you renamed to "newsound2", This means how you name the original sound file does not matter in how you ultimately reference it in the game.