Support for custom Unity packages

Hi,

I would like to share some suggestions regarding possible improvements to the Unity Integration for people/teams like us, who have built their own extensions on top of it in the form of Unity Packages.

We have created our own layer on top of the core components of FMOD so that we can simplify certain workflows and gain other benefits. This extension is created as a Unity Package so that we can easily reuse it in future projects. This resulted in us running into a couple of issues which we think might be worth looking into so that other teams who might be in a similar position in the future have easier time making their own custom packages.

The simpler issue affects the ability to re-use the build-in editor features FMOD comes with. The prime example being the event browser, allowing you to easily reference the audio events you want to play. When making custom components, features like these are priceless and having to re-implement them would be a lot of unnecessary work. Currently the EventBrowser class is not marked as public, making it not possible to use it without having to modify the plugin’s source code. This obviously is not a major issue but having to do this with any future updates would certainly be annoying. Another class in a similar position is EditorUtils. It would be great if these and possibly other editor components were made public by default, making it easier for us to reuse them.

A more complicated problem would be making FMOD not dependant on being placed under the Plugins folder. Ideally, the FMOD integration should be contained inside the our package to preserve the modular nature of packages. Sadly, as of now, a lot of the plugin is coded in a way where it is dependant on being under this specific folder. This caused some early issues with the “images” folder that we had to work around by copying it from the package, which by all means and purposes is not ideal.

This approach worked fine until we started making builds of our project, where we ran into constant errors of platform implementations not being found as they were expected to be under the Plugins folder. The approach of copying them also didn’t help this time around because this resulted in there being duplicate implementations which confused the build process. Not to mention the already stated issue that this should not be the way to handle this because it completely breaks the idea of package structure. There is also the option of just moving the package content from the package folder into the plugins folder but then you run the risk of someone accidentally removing some of it and not being able to fix the issue without completely reimporting the entire package. In the end we were forced to directly change the behaviour of the Platform.GetBinaryFilePaths() method to override where the binaries are looked up.

Dealing with this issue lead us through a lot of hoops that made us aware of a lot of inconsistencies in regards to how file paths are handled throughout the plugin. You would assume that with the plugin folder structure being the same, you would in the worst case only need to change the base path such as the RuntimeUtils.PluginBasePath property. This is sadly not the case, as a lot of places either prepend this path with the “Assets/” string, resulting in invalid path errors or for example straight up directly reference the Application.dataPath field, as is the case in the already mentioned Platform.GetBinaryFilePaths() method. This way of handling paths leads me to believe that either the plugin was build with the clear intention of being placed in this specific folder and/or was later on bent over in a lot of places to at least work there with no thought being put into making it more flexible.

It would be lovely if this could be reworked and make it possible for us to choose the base plugin folder. The plugin folder can still be used as default but being able to set this up in the FMOD settings would be great.

Thanks for considering any of these and sorry for the long post.

Thanks for sharing your feedback.

With the release of 2.02.06, the EventBrowser and EditorUtils are both marked as public. If there are other classes you want to extend that are private in this release, let us know and we’ll consider them. While we don’t officially support developers extending our scripts we also don’t want to get in their way either. With 2.02.06 we did a pass on the entire codebase ensuring explicit public / private is specified. This means many of the default “internal” classes are now public and available for extending.

Regarding your second concern about allowing the FMOD plugin to be placed where you like, we added support for this in 2.02.02. The entire FMOD directory can be moved from the current Plugins directory (a legacy from the old days where Unity required this) and it can now be placed wherever you like. Ensure you also move the FMOD.meta file with the folder, this will ensure when you update the FMOD package it gets installed to the location where you moved it (rather than the default). Our code will use the internal ID of that folder (specified in FMOD.meta) as a method to locate any resources we require inside our package, by doing it this way no configuration is required, simply place it where you like.

If any of this isn’t working for you, please let us know.

Thanks for the quick reply mathew.

It is nice to see that the concern of editor related components being available to us had already been addressed. As a side note, is there a specific time schedule for when the versions higher than 2.02.04 will become Unity verified and available through the package manager?

As for the plugin placement issue, I have tried doing what you said in a new project with a fresh import of the plugin at first. I believe what you said is true as long as the folder with the plugin is somewhere under the Assets folder. Having it inside a package brings up the issue I have already mentioned where a lot of the code assumes that the plugin will be under the Assets folder by prepending the plugin base path by either “Assets/” or Application.dataPath. If the plugin is in a package, the RuntimeUtils.PluginBasePath property updates correctly but because of this prepend a lot of code actually ends up looking for …/Assets/Packages/… which is not valid as the Packages folder is not under the Assets folder.

In order to get it to work in this simplified test case I ended up having to make the following changes:

  • Platform.GetBinaryPaths() - ignore the prefix parameter and return info.LatestLocation()
  • EditorUtils.LoadImage() - remove the “Assets/” prepend from the path string passed into the EditorGUIUtility.Load() call

When applying this approach to our actual package, I ended up making additional changes to some other parts of the code where it seemed like the same issue might rise up. There is definitely more that I either missed, skipped or forgot to take a note of, with the exception being the pieces of code that seemed to deal with obsolete parts of the plugin or older versions:

  • EditorSettings.FmodFolderFull property
  • EditorUtils.StagingSystem - PlatformsFolder & StagingFolder properties
  • EventManager.CacheAssetFullName property
  • PlatformPlayInEditor.GetPluginPath() method
  • FileReorganizer.GenerateTasksForCodeFolders() & GenerateTasksForLooseAssets() methods
  • The FileReorganizer.TaskGenerator also seems like an issue but would require more in-depth refactorization

With this I ended up successfully putting the entirety of the plugin into our package. This created the problem of not being able to modify the FMOD settings in the actual production project because of it being in the package folder that you are not allowed to modify the contents of. I fixed this by making it so that the settings and cache files are created under a settings folder that’s located in the Assets folder. I achieved this by changing the path strings returned by the EventManager.CacheAssetFullName, EditorSettings.FmodFolderFull and EditorSettings.CacheFolderRelative properties and changing the implementation of the EditorSettings.CreateSettingsAsset() method a bit.

Currently, this solution is “ideal” as the plugin is contained within the package and it creates and uses the settings file in the project. Obvisously, being able to do this without having to touch the plugin code would be great, but I understand if that is not a primary goal for you. Although, maybe looking into all those path prepends that break the idea of one component deciding where the plugin is located might be worth the time. At least that way we would avoid having to make all those changes and only deal with changing where the settings and cache files are located.

Thanks once again for the info you have provided. It took some more work but at least we are way happier with the state of our package.

Unity have strict requirements for uploading to the store and sometimes they do not accept our update (leaving the store listing on the old version). We are very close to releasing 2.02.07, this will be the next candidate we submit to Unity for verification, the process usually takes around two weeks, if accepted it will go live on the asset store. You can however always get the latest version from our website.

Regarding moving the FMOD folder you are quite right, my comments were regarding moving it anywhere under the assets directory, i.e. Assets/FMOD or Assets/3rd_party/FMOD. We do not currently support moving it to the packages directory, this is largely because we use the old asset package method, not the new package method. Honestly we’d be keen to switch to the new method, but then we would not be allowed to submit to the asset store and we’re not keen on maintaining two different install methods.

I’ll create an internal task to consider the changes you suggest though, this is all work that would be required if Unity ever permit the new style packages into the store. Any work that is done ahead of that goal should make your integration process less involved.

Hi, we would also like to second this request to support FMOD as a UPM package. Most third-party plugins have now provided support with UPM packages as they are a much better solution to maintaining updates without polluting the project’s Assets folder (something that can easily mess up when a developer tries to update without knowing what they are doing).

Also, like the OP, we have implemented our own extension on top of FMOD as a UPM package to allow sharing it with other projects in our studio. This allowed us to easily maintain and distribute a shared common feature that all our projects uses. To make this process easier, we have been wrapping the FMOD plugin into a standalone UPM package ourselves. It worked pretty well until recently with the new changes that hardcoded the expected paths to be in the Assets folder.

Technically we can do what the OP has done and fix up those hardcoded assumptions. However I do not think that this is a good use of our time if we have to keep maintaining new updates of FMOD’s plugin. I believe there is merit to provide UPM packages as an option. Over time I believe this will become the preferred option for most studios due to the ease of integration and management.

If however there is no plan to support UPM as your main or alternative method of package distribution, we’d like to request that you remove the requirement for hardcoded paths from the package. This at least makes it relatively easy to wrap the plugin in UPM ourselves, and gives developers in general more control over their project structure.

Kind Regards,
Lih-Hern

Second this! UPM support is our most wanted feature for FMOD at our studio.

I’ll create an internal task to consider the changes you suggest though, this is all work that would be required if Unity ever permit the new style packages into the store. Any work that is done ahead of that goal should make your integration process less involved.

Are you certain Unity does not allow you to submit packages to the store? Even if it does not I think it is not a good reason to avoid creating a UPM package of FMOD. Can you not consider creating a GitHub UPM package FMOD repository that we can add directly to Package Manager in Unity? I understand it would be extra work to maintain two solutions but that is something you normally have to do in a transition like this.

Absolutely all third party plugins we currently use have a UPM package available. We also add internal (reusable across projects) plugins/tools to private repositories as packages, because there is so many advantages to the new UPM system.

As for hybrid asset store support, have you looked at this? (native but experimental support added in Unity 2022), this enables you to publish a package to the Asset store:

Please keep us posted on what your conclusions are for this, if this takes to long time to support we would probably consider moving back to native Unity audio in our next project.

Sorry for the rant, but UPM has been the chosen distribution system for Unity for a long time - and we love FMOD and consider it a core plugin for Unity so we are hoping you will support the more modern UPM system!

Thanks for the info, it’s good to see Unity is moving forward with UPM for store submission. I’ve scheduled in the first part of this process, refactoring our implementation to support living outside the assets directory.

1 Like

Wonderful news! Looking forward to updates on this! :slightly_smiling_face:

Hi, do we have any update or roadmap eta on when we will get the new release for fix as mentioned above?

Kind Regards,
Lih-Hern

I don’t have any progress updates to share at this stage, but I can confirm the relocation task is assigned to a developer and the task is in their short term queue so it should be started soon.

1 Like

Hi there again! Do we have an update on this? :slightly_smiling_face:

I can confirm that in our next release you’ll be able to move the FMOD plugin outside of the Assets dir. Our next release should be out in a couple of weeks.

1 Like

Awesome! Thank you so much for the update!

Hi, we noticed that there was a new release that just went out recently. However after checking out the plugin, it does not seem like the release have the fix to allow moving the FMOD plugin outside of the Assets dir. Do we know if this somehow got missed?

My apologies! That feature was descoped from 2.02.13 at the last minute as it needed some more work. Look for it in our next release 2.02.14.

Aha, noted. Thanks for that!

Hi, just following up on this again, but after checking out the latest release (2.02.14), we found that the plugin still does not work correctly when moving to a Package. I am assuming that the work has got descoped again?

Cheers,
Lih-Hern

Correct. The feature is currently in code review - hope to have it out in our next release. Apologies for the delay.

Hi. Version 2.02.16 is out and it doesn’t have this functionality either. We really need support for installing FMOD in Packages. It’s been over a year since this thread started =) Can you please tell us, when you will release this?

It is in 2.02.16. See docs here : https://fmod.com/docs/2.02/unity/user-guide.html#plugin-file-locations