Setting up an FMOD Project + Unity for Collaboration (Git)
Tags: fmod, gamedev, gameaudio, git
Published: 2021-02-01 21:09:53

**This blog post is based on FMOD ver. 2.1**

So I just participated in this year's annual Global Game Jam. This marks my 4th year in this specific jam (besides doing other in between jams over the year). 

My first 2 years, I would take on the role as a composer/sound designer. These past 2 years, since getting into software development, I've been aiming towards wanting to do my technical sound design and audio implementation. 

Okay, enough backstory about myself, let's get to the topic!

## Topics
* Gitignore
* Source Control
* Build Files 
* Other Resources

# Setting up the Gitignore
For many collaborations I've worked in, most programmers have complained how much Git behaves with Unity. Git is notorious with working with Unity. This is also based on my personal endeavors with Git and Unity as well. I'm super glad to finally have found the template to handle FMOD's files into Unity for Git.

Here is the **Gitignore template**:
Reference from [Paalo's post in the FMOD Forums](https://qa.fmod.com/t/fmod-tip-gitignore-for-the-fmod-integration-in-unity-fmod-unity-gitignore/16283)
```
### FMOD Unity Integration ###
# Never ignore DLLs in the FMOD subfolder, so make sure that the 
# FMOD-folder is in the correct path.
!/[Aa]ssets/Plugins/FMOD/**/*.dll

# Don't ignore images and gizmos used by FMOD in the Unity Editor
!/[Aa}ssets/Gizmos/FMOD/*
!/[Aa}ssets/Editor Default Resources/FMOD/*

# Ignore the Cache-file since it is updated locally either way
/[Aa]ssets/**/FMODStudioCache.asset
/[Aa]ssets/**/FMODStudioCache.asset.meta
/[Aa]ssets/Plugins/FMOD/Cache.meta
/[Aa]ssets/Plugins/FMOD/Cache/Editor.meta

# Log-files
fmod.log
fmod_editor.log

# FMOD 1.10.x (Legacy)
/Assets/FMODAssets/*
/Assets/FMODStudioCache.meta
```
With web development, Git is nice with because of the size of files. When it comes to Unity, Unreal Engine, or other game engine, it's a tricky story because now we are dealing with an LFS (Large File Storage) territory. That's for a whole other topic, I've had some failures from a past game jam collaboration trying to incorporate [LFS. You can give it a try here](https://git-lfs.github.com/). 

Audio Files are no joke because we mostly work with .wav & .ogg format. And .wav files can get pretty big, especially in music when dealing with instrumentation, time length, sound libraries, etc. 

Personally, I use .wav when I compose music or sound design in my DAW. Except if I'm using Wwise, I'll still work with .wav, but compress the files into .ogg in Wwise, for compressing file size, but that's going a bit off tangent.

This may differ for other people's setup, when our team was setting up the game project for a Git repo, we had 2 gitignore files. One gitignore was on the outside folder from the Unity Folder, and the other in the actual Unity project folder. I would just copy this **FMOD template** in **both gitignores** just in case.

## Source Control
When using the Git Terminal, the most common commands to utilize is:

This will add all files you want to be pushed to the repo
 ```
git add .
```

You can customize your message, that will be seen on the repo, best to add a message that relates to your latest progress you made
```
git commit -m "add commit message here"
```

You are grabbing the files from the repo in case other collaborators pushed their files and changes.
```
git pull
```

You push up your files and changes.
```
git push 
```
When collaborating with others, it's safer to **git pull** before **git push** in order to avoid less merge conflicts (which will happen, it WILL HAPPEN). 

=============
3/15/21 Edited
```
git reset --hard <commit code number> //
```
The commit code number usually looks like a string of random letters and numbers like this (without the < > surrounding):
64f31ej5q1684028501w1389ui67nv2z745h7234

Which can be found in the git repo, That's what those git commit messages are for!

Git reset is used to revert back to a previous commit, or previous version if you find yourself messing up on your current progress.

=============

Just based on experience, the other collaborators will somehow get some meta or cache FMOD files from your pushes. Your FMOD project is the main one that you will be merging anyway to resolve since you are in charge of making changes to those FMOD files. 

## Build Files
Creating the export files differs on which route you take on how you import them into your Unity project. It's listed in the FMOD Documentation here: [Accessing Your FMOD Studio Content](https://fmod.com/resources/documentation-unity?version=2.0&page=user-guide.html#setting-up) 

Which they do a wonderful job explaining it, but I can try to add on my experience as well.

So in Unity (after installing FMOD into your project), on the top menu, go to:
FMOD -> Edit Settings 

And inspector should open **FMODStudioSettings** 

![FMOD Studio Settings](https://dev-to-uploads.s3.amazonaws.com/i/4hu0twtiu9r554lc84xz.png)

There are three ways on how you want to share your FMOD files into the collaboration space. 

1. Project
2. Single Platform Build
3. Multiple Platform Build

**Project**: This way, you can drag your whole FMOD Project Folder and add it into your Assets Folder in Unity (to be in the folder level next to scripts folder, prefabs folder, scenes folder, etc.)

Looking for the .fspro project file.

This would probably be used if you are collaborating with multiple game audio members who need access to FMOD project, because you are essentially adding the whole project folder into the Unity folder. This also means that there might be complications with the other non-audio members that don't want to deal with merge conflicts of accidentally altering any files with FMOD, whether it could be from hidden meta or cache files. 

**Single Platform Build**: This way is instead of bringing your whole FMOD Project folder into the Unity Assets Folder, you just need to bring in the bank files you generated from FMOD. In case you're not sure how to generate the bank files:

File -> Build

![File Build](https://dev-to-uploads.s3.amazonaws.com/i/jj0ga4qvny6vn6n9ufyo.png)

It should have generated these files.

![Build Files](https://dev-to-uploads.s3.amazonaws.com/i/s9aw7062zk6lylr0cxz8.png)

When you have installed FMOD to your Unity Project already, you should have two folders called "Gizmos" & "Plugins" generated in the Unity Main Assets folder:

![Unity Assets](https://dev-to-uploads.s3.amazonaws.com/i/jc8jfyha3eyddx4614gd.png)

Gizmos carries the an FMODEmitter file, while the Plugins carries the cache data. 

You can create a new folder in the Unity Assets Folder, calling it "FMOD Banks" (feel free to name it the way you want, as long as you negotiate to your collaborators for file/folder name conventions) for organizational purpose. 

For me, I dragged the FMOD Master.bank & Master.strings.bank files into the FMOD Banks folder. I created the FMOD Banks folder in Gizmos (you don't have to only place it there). I would have probably just place FMOD Banks Folder in the main Assets Folder. 

You can also set up an automation location of where you want your FMOD builds to generate.

Preferences -> Build Tab -> Browse where you want to generate the build files

In this case, you would place them into your FMOD Banks folder in your Unity Assets.

![Preference](https://dev-to-uploads.s3.amazonaws.com/i/dfsk0q14xgq0t0ggfy2i.png)

![Build Export](https://dev-to-uploads.s3.amazonaws.com/i/lma96o7brlmjhuz6qgcy.png)

**Multiple Platform Build**: This way is when importing from multiple sub directories. Personally, I have not used this yet because I have not built a game in this scope yet. However, in the FMOD documentation, its use is when you want to use separate .Bank files for separate builds based on each platform (console, PC, Mac, mobile, etc.).

The main goal is having the files in the Unity Project folder in order to keep it in scope of where the Git Repo is located. 

I've been curious about looking at alternatives of Git with Game development. I've been suggested Perforce, which I'll probably look into the future since I've heard that is AAA studio standard. I think it's because Git is open source and easily accessible to a wide audience, which commonly most people go to for source control.

My way of working with FMOD may not fit for everyone, feel free to add your workflow with it. I'm mainly sharing my experience that I've had a rough time before with dealing with setups for collaborations but now finding something that actually worked for me.

I just hope this helps with game audio folks getting into collaborative projects.

Here are more resources for things discussed in this blog.

[Gitignore](https://www.atlassian.com/git/tutorials/saving-changes/gitignore)

[How to use gitignore file](https://www.pluralsight.com/guides/how-to-use-gitignore-file)

[Git LFS (Large File Storage)](https://git-lfs.github.com/)

[Getting Started in FMOD](https://fmod.com/resources/documentation-unity?version=2.0&page=user-guide.html#using-a-multiple-platform-build)

[Perforce](https://www.perforce.com/)