About make plugin to unity package and modify FMODStudioSettings

To make it easier to manage and to add some of the features I needed, I referenced the following:

  1. Support for custom Unity packages - Unity - FMOD Forums
  2. FMOD - User Guide (plugin file locations)

Made the plugin into a unity package and stored it in a git repository, but a problem arose.

If a package is added from git, then all its files are stored under the Library\PackageCache path and all files are read-only.
However, if you want to use the FMOD plugin, you must need to modify the FMODStudioSettings.asset file in it.
What should I do about this problem that causes conflicts? Do I need to modify the plugin’s code to adjust the path to find the FMODStudioSettings.asset file?

One more question, does name in package.json have to be
com.firelight.fmod-for-unity ?

I noticed a few details:
When I import the .unitypackage file, there are a total of 6 folders under the Assets path, addons, images, obsolete, platforms, src and staging.

But when I import, obsolete, staging and platforms\mac files are not imported.
And the Cache and Resources folders are automatically created.

Should obsolete, staging, and platforms\mac files all be packaged in the package as well?
Should Cache and Resources be ignored?

The FMODStudioSettings.asset is a generated file needs to be able to be modified, so it would be best not to add this to the git repo. Unity should make a local version that it can modify as needed.

No, it doesn’t need to be com.firelight.fmod-for-unity. This is the naming convention that Unity use for the UPM but the integration doesn’t rely on that particular folder name.

The folders obsolete and staging are only used for updating the integration, it will attempt to replace older versions of certain files and then either move or delete them from these folders. You can ignore these as they are not meant to hang around after the initial editor compilation.

Cache and Resources will only contain files that are generated locally, depending on the settings in Unity. They should not be added otherwise, as mentioned in your original post, they will be read-only.

As for the platforms/mac folder, it should contain libs and source files but if you aren’t using mac (same goes for other platforms) then you do not need to include them.


It seems like this is something we should specify in our documentation, so I will create a task to add it.

You basically want to include the FMOD folder, then ignore the Cache and Resources folders. All the other folders and files should be added to the repo.

Thanks for the reply, I think I need to describe a bit more the results of my current quest.

First is my purpose, I want to convert FMOD into a Unity Package and version control it via Git.


After following the steps provided in the documentation so far, I was able to successfully make the Unity Package.
After I uploaded it to Git, I was also able to install it by adding a git URL to UPM.

However, it seems that for Unity, if a Unity Package is installed via a git URL, all of its files will be placed in the {ProjectName}\Library\PackageCache directory, and all of the files there will not be editable via the Unity Editor.

I tried ignoring the Cache and Resources folders and leaving them out of the Unity Package, but this causes Unity to output a lot of Warnings in the Console.

I noticed that you mentioned

Cache and Resources will only contain files that are generated locally, depending on the settings in Unity.

But I tried and couldn’t find anything like that, can you provide more information?


Also, if you add the Unity Package to git, it prompts a message after installation. I found two posts in the forum for the same issue:

  1. Incorrect line endings in Fmod plugin bundles - FMOD Studio - FMOD Forums
  2. Repair FMOD Libraries warning still keeps showing after click repair button - Unity - FMOD Forums

I followed the instructions in the posts and added the .gitattributes file, but still have the same problem.

I double-checked, through the Unity Console messages, and comparing the folders, and realized that it was not the three folders:

  • Packages/{UnityPackageName}/FMOD/platforms/mac/lib/fmodstudio.bundle
  • Packages/{UnityPackageName}/FMOD/platforms/mac/lib/fmodstudioL.bundle
  • Packages/{UnityPackageName}/FMOD/platforms/mac/lib/resonanceaudio.bundle

Instead, it was the three files:

  • Packages/{UnityPackageName}/FMOD/platforms/mac/lib/fmodstudio.bundle/Contents/Info.plist
  • Packages/{UnityPackageName}/FMOD/platforms/mac/lib/fmodstudioL.bundle/Contents/Info.plist
  • Packages/{UnityPackageName}/FMOD/platforms/mac/lib/resonanceaudio.bundle/Contents/Info.plist

So I changed the contents of the .gitattributes file to *.plist text eol=lf.

But the problem is still not solved.
I double-checked the files again and found that the local files were LF, uploaded to git and then downloaded were still LF, and for some reason installing via UPM made them CRLF first (in {ProjectName}\Library\PackageCache folder).

So I’m not sure if the problem belongs to FMOD, or Git, or UPM.


Regardless of the outcome, thanks again for your reply.

I’m back to share my new research.
After analyzing the code, I found that the paths to the Resources and Cache folders are determined based on these properties:

  • FMODUnity.RuntimeUtils.BaseFolderGUID
  • FMODUnity.RuntimeUtils.PluginBasePathDefault
  • FMODUnity.RuntimeUtils.PluginBasePath

Just modify the appropriate section and you can use it.
Example:

  • FMODUnity.CreateSettingsAsset() method - FMODStudioSettings.asset file.
  • FMODUnity.EventManager.CacheAssetFullName property - FMODStudioCache.asset file.

But I still haven’t solved the problem about LF and CRLF.

I think I found the problem.

Unity actually adjusts the downloaded files based on the .gitattributes file .
And the way I installed it is: http : / /gitlab.xxxxx.com/unitypackage_pub/fmod.git?path=com.xxxxx.fmod#1.x.x

This causes UPM to download a Package without the .gitattributes , thus using the default processing to change all the files to CRLF.

The solution is also simple, just move the .gitattributes file to the com.xxxxx.fmod folder.

1 Like

Thanks for all the information, I’ve made a task to investigate this further.

1 Like