Hello!
With the latest (and perhaps earlier?) Unity-approved fmod integration, adding an fmod track & clip to a unity timeline works fine, but editing the clip at all (changing length, or switching events) causes it to spit out the following error:
[FMOD] RuntimeManager accessed outside of runtime. Do not use RuntimeManager for Editor-only functionality, create your own System objects instead.
since the error happens in CreatePlayable
, the result is a null playable, rendering the entire timeline useless for in-editor previewing and editing.
The source issue seems to be the RuntimeManager.GetEventDescription(EventReference);
call, which should only happen at runtime, but is used here at edit-time and runtime.
public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
{
#if UNITY_EDITOR
if (!EventReference.IsNull)
#else
if (!CachedParameters && !EventReference.IsNull)
#endif
{
FMOD.Studio.EventDescription eventDescription = RuntimeManager.GetEventDescription(EventReference);
for (int i = 0; i < Parameters.Length; i++)
{
FMOD.Studio.PARAMETER_DESCRIPTION parameterDescription;
eventDescription.getParameterDescriptionByName(Parameters[i].Name, out parameterDescription);
Parameters[i].ID = parameterDescription.id;
}
List<ParameterAutomationLink> parameterLinks = Template.ParameterLinks;
for (int i = 0; i < parameterLinks.Count; i++)
{
FMOD.Studio.PARAMETER_DESCRIPTION parameterDescription;
eventDescription.getParameterDescriptionByName(parameterLinks[i].Name, out parameterDescription);
parameterLinks[i].ID = parameterDescription.id;
}
CachedParameters = true;
}
Hi,
Thank you for bringing this to our attention. I will pass this on to our development team to look into further.
A workaround is commenting out lines 125 - 129
in RuntimeManager.cs
. Keep in mind this may cause unexpected behavior and restarting Unity should resolve most of them. I understand this isn’t ideal.
Thank you again.
What’s the status on this fix?
Hi,
The fix was included in the latest update 2.02.14, unfortunately, this is not a Unity-verified version. Our next release will be submitted for Unity verification.
Hope this helps!
1 Like
Any helps from this? I got this error as well in Timeline.
My version is 2.02.21, downloaded from Unity Assets Store
Hi,
Could I please get reproduction steps? Using FMOD 2.02.21, playing an event in the timeline I was not able to reproduce the error.
The codes i am runing is in Unity edit mode, not play mode. Play mode works fine for me.
I’ve created an audio clip component in the Unity Timeline editor, this allows me to configure the audio. The component reads the properties like ‘length’ of the event, and after clicking the play button on Unity Timeline, I can preview the sound. The methods I’ve used are ‘RuntimeManager.PlayOneShot()’, ‘RuntimeManager.GetEventDescription()’, and similar APIs. These used to work directly with version 1.0, but after upgrading to version 2.0, they no longer work. I encountered errors like 【‘[FMOD] RuntimeManager accessed outside of runtime. Do not use RuntimeManager for Editor-only functionality, create your own System objects instead.’】 And ‘event not found’.
I also don’t quite understand the meaning of ‘create your own System objects instead’. Does ‘System objects’ refer to using Unity’s own audio system? Furthermore, I’m uncertain about the parameters to input when using the following methods:
FMOD.Studio.System.create(out editor_system);
editor_system.initialize(10,FMOD.Studio.INITFLAGS.NORMAL, FMOD.INITFLAGS.NORMAL,0);
Especially the last parameter ‘IntPtr extradriverdata’, the official website notes it as ‘opt’, but the code forces me to enter it. I just want to preview the sound in mode other than play mode."
1 Like
Update:
I have tried using FMODUnity.EditorUtils.System.getEvent(path,out var _eventdes) and it can indeed make a sound. However, when I copied the code for creating the system from EditorUtils and tried to load the bank, I was unable to successfully load the Bank. What could be the reason for this?
public static FMOD.Studio.System custom_sysytem;
public playAudio(string path){
custom_sysytem = CreateSystem()
custom_sysytem .getEvent(path,out var _eventdes);
_eventdes.createInstance(out var _event);
_event.start()
}
private static FMOD.Studio.System CreateSystem()
{
RuntimeUtils.DebugLog("FMOD Studio: Creating editor system instance");
RuntimeUtils.EnforceLibraryOrder();
FMOD.RESULT result = FMOD.Debug.Initialize(FMOD.DEBUG_FLAGS.LOG, FMOD.DEBUG_MODE.FILE, null, "fmod_editor.log");
if (result != FMOD.RESULT.OK)
{
RuntimeUtils.DebugLogWarning("FMOD Studio: Cannot open fmod_editor.log. Logging will be disabled for importing and previewing");
}
FMOD.Studio.System.create(out var system);
FMOD.System lowlevel;
system.getCoreSystem(out lowlevel);
// Use play-in-editor speaker mode for event browser preview and metering
var speakerMode = Settings.Instance.PlayInEditorPlatform.SpeakerMode;
lowlevel.setSoftwareFormat(0, speakerMode, 0);
var encryptionKey = Settings.Instance.EncryptionKey;
if (!string.IsNullOrEmpty(encryptionKey))
{
FMOD.Studio.ADVANCEDSETTINGS studioAdvancedSettings = new FMOD.Studio.ADVANCEDSETTINGS();
system.setAdvancedSettings(studioAdvancedSettings, encryptionKey);
}
system.initialize(256, FMOD.Studio.INITFLAGS.ALLOW_MISSING_PLUGINS | FMOD.Studio.INITFLAGS.SYNCHRONOUS_UPDATE, FMOD.INITFLAGS.NORMAL, IntPtr.Zero);
FMOD.ChannelGroup master;
lowlevel.getMasterChannelGroup(out master);
FMOD.DSP masterHead;
master.getDSP(FMOD.CHANNELCONTROL_DSP_INDEX.HEAD, out masterHead);
masterHead.setMeteringEnabled(false, true);
_initBanks(system);
return system;
}
private static void _initBanks(FMOD.Studio.System system)
{
system.unloadAll();
foreach (EditorBankRef bankRef in EventManager.Banks)
{
FMOD.Studio.Bank bank;
string dataPath = Application.dataPath;
string originalString = bankRef.Path;
string characterToRemove = "Assets";
int index = originalString.IndexOf(characterToRemove);
if (index >= 0)
{
bankRef.Path = originalString.Substring(index);
}
var resulyt = system.loadBankFile(bankRef.Path, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out bank);
Debug.Log(resulyt);
}
}
Thank you for the information.
Can you elaborate on how you are triggering the events? Is it through the Timeline options or are you using code? If so, would it be possible to see the full code you are using to trigger the sounds?
No, as you have found it is creating your own FMOD system.
Would it be possible to add FMOD_RESULT calls to the FMOD functions when creating the FMOD system and loading the banks? This will help us resolve the issue.