Coder Social home page Coder Social logo

fmod-for-unity's Introduction

FMOD For Unity

This repository contains the source code for the FMOD Studio Unity integration, excluding any platforms that require a non-disclosure agreement (such as Xbox). Additionally, native binaries for all platforms have been removed and must be acquired from a built Unity package. Developers can use this repository to track changes, report issues or submit modifications.

  • Packages which include binaries can be downloaded from the Unity asset store or the FMOD download page.
  • For getting started information, up-to-date documentation and compatibility details check the FMOD For Unity documentation site.
  • Free support is available on the FMOD forums for all users, paid / licensed support available by email.

fmod-for-unity's People

Contributors

drichardson avatar farshidhss avatar fmod-andrew avatar fmod-cameron avatar fmod-mathew avatar fmod-nick avatar gregharding avatar kentmw avatar kyleorth avatar m6502 avatar mltimk avatar msklywenn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fmod-for-unity's Issues

Package Manager

Hello,

Is there any plans to "upgrade" this fmod unity integration to the new package manager format? It would probably make it easier and less messy when integrating to other projects. I'm about to do it for our project. I can make a pull request when I'm finished if that is of any interest.

https://docs.unity3d.com/Manual/CustomPackages.html

Bank changes are ignored in Addressables Content Update

When using Addressables with FMOD for Unity, there is a feature that automatically executes EventManager.CopyToStreamingAssets and EventManager.UpdateBankStubAssets using Scriptable Build Pipeline PostDependencyCallback and PostWritingCallback. However, this causes issues when utilizing Addressables' Content Update feature.

To use the Content Update feature, the hash values of all individual entries going into Addressables are recorded in the addressables_content_state.bin file. However, referring to the BuildScriptPackedMode.cs script, the action of recording hash values occurs after the AssetBundle build. After the AssetBundle build is complete, FMOD automatically calls EventManager.UpdateBankStubAssets through PostWritingCallback. As a result, the hashes recorded in the addressables_content_state.bin file are all hashes of Stub Assets. Therefore, it becomes impossible to record the hash value of the FMOD Bank, and any changes to the FMOD Bank are omitted from all content updates.

To address this issue most simply, it would be preferable to make the automatic functionalities of EventManager.CopyToStreamingAssets and EventManager.UpdateBankStubAssets using Scriptable Build Pipeline optional. Currently, when using Addressables and FMOD simultaneously while trying to utilize the Content Update feature, it is inconvenient as it requires modifying scripts within FMOD for Unity.

Unity Build Error

I’m getting the following errors in unity trying to create a build.(Switch buld)
‘xx_VERSION’ does not contain a definition for ‘dll’

FMOD unity 2.02.19
Switch sdk 17.5.3
unity editor 2022.3.16

Assets\Plugins\FMOD\src\fmod_studio.cs(384,35): error CS0117: 'STUDIO_VERSION' does not contain a definition for 'dll'

Assets\Plugins\FMOD\src\fmod_studio.cs(1483,35): error CS0117: 'STUDIO_VERSION' does not contain a definition for 'dll'

Assets\Plugins\FMOD\src\fmod_studio.cs(1774,35): error CS0117: 'STUDIO_VERSION' does not contain a definition for 'dll'

Assets\Plugins\FMOD\src\fmod.cs(975,28): error CS0117: 'VERSION' does not contain a definition for 'dll'

Assets\Plugins\FMOD\src\fmod_studio.cs(1485,35): error CS0117: 'STUDIO_VERSION' does not contain a definition for 'dll'

I don’t know if there’s anyone with the same problem as me who can help me… thank you

2.00.00 WebGL : Unsupported?

Got the latest version of the unitypackage.
Works better than a few days ago.

Build for PC and Mac work fine.
When I switch to Build for WebGL
errors and stays it is unsupported

Unity 2018 3 11f1 Personal - fmodAudioTest unity - FMOD2Test - WebGL (Personal)  Metal  2019-03-31 19-43-08

Unity Console spamming: "ArgumentException: The specified path is not of a legal form (empty)"

I looked this issue up in google and found no help, so I'm posting here.

I'm using the latest version of unity: 2019.2.17f1
And latest version of FMOD unity plugin: 2.00.06
Visual studio version: Microsoft Visual Studio Community 2019, Version 16.4.2

I create a new Empty unity project, install the plugin, Add an FMOD project folder.
I add a single script to an empty scene:

public class TestFMOD : MonoBehaviour
{
    private EventInstance audio;

    void Start()
    {
        audio = FMODUnity.RuntimeManager.CreateInstance("event:/Level1/Music1"); 
        audio.start();
    }
}

When I ran the scene, the music plays with no issues, but the console keep spamming hundreds of this error message, this makes it impossible for me to locate actual errors in my own code as they get swallowed by this immediately:

ArgumentException: The specified path is not of a legal form (empty).
System.IO.Path.InsecureGetFullPath (System.String path) (at <567df3e0919241ba98db88bec4c6696f>:0)
System.IO.Path.GetFullPathInternal (System.String path) (at <567df3e0919241ba98db88bec4c6696f>:0)
System.IO.FileInfo.Init (System.String fileName, System.Boolean checkHost) (at <567df3e0919241ba98db88bec4c6696f>:0)
System.IO.FileInfo..ctor (System.String fileName) (at <567df3e0919241ba98db88bec4c6696f>:0)
(wrapper remoting-invoke-with-check) System.IO.FileInfo..ctor(string)
UnityEditor.VisualStudioIntegration.SolutionSynchronizer.ShouldSyncOnReimportedAsset (System.String asset) (at C:/buildslave/unity/build/Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs:224)
System.Linq.Enumerable.Any[TSource] (System.Collections.Generic.IEnumerable`1[T] source, System.Func`2[T,TResult] predicate) (at <351e49e2a5bf4fd6beabb458ce2255f3>:0)
UnityEditor.VisualStudioIntegration.SolutionSynchronizer.SyncIfNeeded (System.Collections.Generic.IEnumerable`1[T] affectedFiles, System.Collections.Generic.IEnumerable`1[T] reimportedFiles) (at C:/buildslave/unity/build/Editor/Mono/VisualStudioIntegration/SolutionSynchronizer.cs:213)
UnityEditor.SyncVS.PostprocessSyncProject (System.String[] importedAssets, System.String[] addedAssets, System.String[] deletedAssets, System.String[] movedAssets, System.String[] movedFromAssetPaths) (at C:/buildslave/unity/build/Editor/Mono/SyncProject.cs:165)
UnityEditor.AssetPostprocessingInternal.PostprocessAllAssets (System.String[] importedAssets, System.String[] addedAssets, System.String[] deletedAssets, System.String[] movedAssets, System.String[] movedFromPathAssets) (at C:/buildslave/unity/build/Editor/Mono/AssetPostprocessor.cs:159)
UnityEditor.AssetDatabase:SaveAssets()
FMODUnity.EventManager:CopyToStreamingAssets() (at Assets/Plugins/FMOD/src/Editor/EventManager.cs:584)
FMODUnity.EventManager:RefreshBanks() (at Assets/Plugins/FMOD/src/Editor/EventManager.cs:37)
FMODUnity.EventManager:Update() (at Assets/Plugins/FMOD/src/Editor/EventManager.cs:656)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions() (at C:/buildslave/unity/build/Editor/Mono/EditorApplication.cs:303)

Am I doing something wrong or is this a bug?

CopyToStreamingAssets() called twice in a row?

In version v1.10.20 Unity integration package CopyToStreamingAssets() is called twice in a row when invoked via EventManager.Update. Once in OnCacheCange at the end of the method and again right after that in Update.

Also in EventManager.CopyToStreamingAssets in the last iteration loop you call AssetDatabase.SaveAssets every loop. Is that necessary? Can you not call it at the end of the loop?

This along with how often this method is invoked via Update is slowing down iteration time when working in the editor. It is invoked entering play mode or recompiling scripts when none of the FMOD bank assets have changed.

Git URL for package only - Request

Is it possible for you to provide a Git URL for the FMOD integration that Unity will recognise as a custom unity package (i.e. https://docs.unity3d.com/Manual/CustomPackages.html)?

It would be really handy to add a project dependency for the FMOD integration directly into a Unity project's manifest.json (as outlined in the Unity manual here: https://docs.unity3d.com/Manual/upm-git.html), as it would be essentially be manageable through the package manager and automatically updated.

Reimporting manually is fine - just trying to see where I can improve my workflow.

FMODStudioCache causing deserialisation exceptions when Resource.LoadAll() is used in a build.

Because the FMODStudioCache uses editor-only classes, it might cause errors if it is still present in a build, when unity tries to load and deserialize it.
This could happen when a script uses Resources.LoadAll("").

A solution to this problem would be to move the FMOD studiocache into an Editor folder.
So when looking at FMODUnity.EventManager in EventManager.cs changing the path on line 17 to:
const string CacheAssetFullName = "Assets/Plugins/FMOD/Editor/Resources/" + CacheAssetName + ".asset";
would fix the issue.
This will result in the asset not being included in a build.

FMOD does not play nice with Unity's "Configurable Enter Play Mode"?

Hi,

after turning on Configurable Enter Play Mode and disabling scene/domain reloading, FMOD does not seem to like that. We start to get many exceptions that we would not normally get if we did domain reloading e.g. [FMOD] Event not found (for events that actually exist). Seems to be due to all the static and native DLLs state that fmod has. Would be really nice to support this play mode as we can't turn it on right now unless we disable FMOD.

More info: https://forum.unity.com/threads/configurable-enter-play-mode.768689/

Thanks!

[EDIT]: Turns out it was a IsInitialized static boolean in our static audio wrapper that wasn't reset properly. Just needed to reset it in [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]

How do I change advanced settings from script?

The API leads me to believe I can change things like the idle sample data pool size. But in practice if I try to change these I get:

[FMOD] Manager::setAdvancedSettings : Cannot set advanced settings after Studio initialization

Looking over the source code, it appears the architecture is singleton-driven, so fetching the RuntimeManager calls initialize. And I have to fetch the RuntimeManager to change the advanced settings. Is this impossible?

AttachInstanceToGameObject removes stopped instances

I'm probably misunderstanding something, but AttachInstanceToGameObject automatically removes instances that are in a stopped playback state.

My use case: I have a footstep event instance on my character class. I want to allocate the event instance and Attach it exactly once, in Start. I then want to play the footstep sound based on an animator callback, and have the 3D attributes automatically relayed. That seems to be the use case Attach was designed for, no? But it's essentially a noop: the instances are removed immediately after I call attach, because they haven't been played yet.

The only way to get this to work is to call set3DAttributes every Update, or just before the event is started. Which is fine and it works, but has me wondering: what is the purpose of AttachInstanceToGameObject?

public class CharacterBase : MonoBehaviour {
  protected EventInstance _stepEvent;

  protected void Start() {
    _stepEvent = RuntimeManager.CreateInstance(_asset.StepSoundEvent);
    RuntimeManager.AttachInstanceToGameObject(_stepEvent, transform, _rigidBody); // has no effect, the attached instance is discarded immediately
  }

  protected void PlayStepSound() {
    _stepEvent.start();
  }
}

What is his purpose?

image

Banks location in Streaming assets folder

Hi,
I've just updated fmod studio and fmod integration package to latest version (2.00.01). It solved my problem with error about copying banks to Streaming assets folder. However I am experiencing another issue.

image

How you can see on the image, from some reason MasterBank and MasterBank.strings are outside of StreamingAssets/Assets/Fmod/Build/Desktop. These folder are created by fmod itself and when I delete them they will appear again. It's not big issues, but I like my project clean :-).

Any idea if I am missing some settings or it is a bug?

Thanks for your help,

Jakub.

Avoid minor GC Alloc by adding basic utilities

I noticed the RuntimeManager has GC Alloc of a few hundred bytes per frame which isn't a lot but it is an unnecessary distraction for anyone optimizing performance.

For example, RunTimeManager calls GetSetting in Settings.cs, which has the line

T t = list.Find((x) => x.Platform == platform);

which causes the alloc. A simple utility like below would avoid this:

T FindInList<T>(List<T> list, Predicate<T> predicate)
{
  for (var i = 0; i < list.Count; i++)
  {
    var item = list[i];
    if (predicate(item))
    {
      return item
    }
  }
  return default(T);
}

Can anyone provide clarity as to where such a utility would go / how it should be set up for the coding style of this project? A new file called "BasicUtilities.cs" perhaps?

"Update Event References" Scan throws errors and fails. Unity 2022.3.18f1 URP

Scanning for references fails. Seems to access the UniversalAdditionalCameraData component for some reason. I have no idea why the volume trigger would be accessed by it. Nothing in my code base hooks onto scene changes in the editor or anything like that.

UnassignedReferenceException: The variable m_VolumeTrigger of UniversalAdditionalCameraData has not been assigned.
You probably need to assign the m_VolumeTrigger variable of the UniversalAdditionalCameraData script in the inspector.
UnityEngine.Transform+Enumerator.MoveNext () (at <f7237cf7abef49bfbb552d7eb076e422>:0)
FMODUnity.EventReferenceUpdater+<GetGenericUpdateTasks>d__45.MoveNext () (at Assets/Plugins/FMOD/src/Editor/EventReferenceUpdater.cs:690)
FMODUnity.EventReferenceUpdater+<SearchGameObject>d__37.MoveNext () (at Assets/Plugins/FMOD/src/Editor/EventReferenceUpdater.cs:337)
FMODUnity.EventReferenceUpdater+<SearchPrefabs>d__34.MoveNext () (at Assets/Plugins/FMOD/src/Editor/EventReferenceUpdater.cs:230)
System.Linq.Enumerable+ConcatIterator`1[TSource].MoveNext () (at <bb4b38eec2634f5887af2d644ab0aceb>:0)
FMODUnity.EventReferenceUpdater.UpdateProcessing () (at Assets/Plugins/FMOD/src/Editor/EventReferenceUpdater.cs:1761)
UnityEditor.EditorApplication.Internal_CallUpdateFunctions () (at <8e887700cd7e4674989da7b046e8eaa6>:0)

SystemNotInitializedException: [FMOD] Initialization failed : FMOD.System.setOutput : ERR_INVALID_HANDLE : An invalid object handle was used.

Hello, I have a SystemNotInitializedException problem, my runtime platform is xbox development machine, build from unity 2019.4.29f1 GameCore-Scarlett platform, fmod version is 2.00.08, and I have disable Unity audio.
I got the fmodstudioapi20008gamecore_gdk191100-installer from Microsoft account manager, but in FMODStudioSettings I just see XBox One under the Console, not scarlett, and Plugins is empty, I use dll instead of lib, it's a wrong setting?
I add a FMOD Studio Listener in scene, and call "RuntimeManager.Init();"
Plz tell me how to fix this exception, thank you!

SystemNotInitializedException: [FMOD] Initialization failed : FMOD.System.setOutput : ERR_INVALID_HANDLE : An invalid object handle was used.
  at FMODUnity.RuntimeManager.CheckInitResult (FMOD.RESULT result, System.String cause) [0x00000] in <00000000000000000000000000000000>:0 
  at FMODUnity.RuntimeManager.Initialize () [0x00000] in <00000000000000000000000000000000>:0 
  at FMODUnity.RuntimeManager.get_Instance () [0x00000] in <00000000000000000000000000000000>:0 
  at FMODUnity.RuntimeManager.AddListener (FMODUnity.StudioListener listener) [0x00000] in <00000000000000000000000000000000>:0 
  at FMODUnity.StudioListener.OnEnable () [0x00000] in <00000000000000000000000000000000>:0 

IOException when copying FMOD 2.0 Banks

Hi! I'm getting these errors with FMOD 2.0 Unity integration.

FMOD Studio: copy banks for platform Windows : copying banks from D:\Development\Death Crown\death-crown\FMOD_Project\Build\Desktop to D:/Development/Death Crown/death-crown/Assets/StreamingAssets

FileNotFoundException: D:\Development\Death Crown\death-crown\FMOD_Project\Build\Desktop\FMOD_Project\Build\Desktop\Master.strings.bank does not exist
System.IO.File.Copy (System.String sourceFileName, System.String destFileName, System.Boolean overwrite) (at <ac823e2bb42b41bda67924a45a0173c3>:0)
FMODUnity.EventManager.CopyToStreamingAssets () (at Assets/Plugins/FMOD/src/Editor/EventManager.cs:549)
UnityEngine.Debug:LogException(Exception)
FMODUnity.EventManager:CopyToStreamingAssets() (at Assets/Plugins/FMOD/src/Editor/EventManager.cs:561)
FMODUnity.EventManager:OnCacheChange() (at Assets/Plugins/FMOD/src/Editor/EventManager.cs:602)
FMODUnity.EventManager:Update() (at Assets/Plugins/FMOD/src/Editor/EventManager.cs:614)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

I've already read this thread https://qa.fmod.com/t/streamingassets-fail-to-copy-due-to-invalid-path-name-in-eventmanager-cs-upgrade-to-2-00-00-integration/14479
I've reinstalled Unity integration from this repo, deleted FMODStudioCache.asset, rebuilt the banks, but I'm still getting these errors. I believe something is still quite wrong.

FMOD Studio 2.0
Unity 2018.3.0f2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.