Global Parameter not showing in event browser

Hi it seems that only continuous global parameters are showing in Unity, is this normal?

I’m seeing the same thing. Not sure if this is a bug or just not supported.

I mentioned in burnum’s thread that this is a bug and it will be looked into in a future version. Thanks for bringing this to our attention.

thanks I will feed this back to my class :slight_smile:

Is there any prediction of what “in a future version” means time-wise? :smiley:
Just to understand if we can consider this to be fixed within our production timeline, or if we should find alternative ways to provide the game values to the engine (e.g. multiple local variables)

im using continuous for now, not really much of a huge issue

Unfortunately we can’t promise an exact time frame. You are able to change the parameter to continuous and use this instead if you are pressed for time.

I’m having this issue too, any work arounds or fixes for this issue?

This should have been fixed in the latest FMOD Studio 2.01 Unity integration. Can you confirm you are using the latest version?

Hi @richard_simms
I ran into this issue in 2.01.08 today.

After some digging I came up with the following (also mailed this to support)

The problem:
Global parameters aren’t available in the build in components such as the StudioGlobalParameterTrigger even if there are global params in the project.
Whenever we delete the FMODStudioCache, the parameters do become available again but as soon as a bank refresh occurs or when we hit the play button, all global event entries are deleted.
This causes editor errors and effectively breaks all setups afterwards, basically making the use of the global parameters completely not viable.

The Cause:
I was able to pinpoint the cause of the issue to EventManager.cs script and more specifically to line 240:

eventCache.EditorParameters.ForEach((x) => x.Exists = false);

What seems to be happening that each time a refresh it triggered, all parameters are flagged to no longer exist.
At line 307 the false flagged entries are then all removed:

eventCache.EditorParameters.RemoveAll((x) => !x.Exists);

There is however an issue in the fact that nowhere in the function, the parameters are set to exitst or readded if needed…
This only happens if there was an update to the bank that is being checked.
This can be seen at line 264:

// Timestamp check - if it doesn’t match update events from that bank
if (bankRef.LastModified != bankFileInfo.LastWriteTime)
{
bankRef.LastModified = bankFileInfo.LastWriteTime;
UpdateCacheBank(bankRef);
}

The addition and updating of the global cached parameters happens inside the UpdateCacheBank method and thus if nothing changed to the banks, all parameters will always be flagged to no longer exist and will be cleaned up.
Unless there was a modification made to the bank that contains the data in question.

The Solution (potentially):
In order to try to fix this on my end I have made some alteration to the code to catch this but I’m not sure if this will /could lead to other issues. Either way here is the fix that I have made on our end.
At line 264:
Changed the if check as follows:

// Timestamp check - if it doesn’t match update events from that bank
if (bankRef.LastModified != bankFileInfo.LastWriteTime)
{
bankRef.LastModified = bankFileInfo.LastWriteTime;
UpdateCacheBank(bankRef);
}
else
{
//as we flagged all editor parameters (aka global parameters) to be deleted we need to make sure that the ones we want to keep remain
//Update global parameter list for each bank
UpdateCacheBankEditorEvents(bankRef);
}

At line 442:
And I added the following method based on the UpdateCacheBank method but only to update the editor events:

static void UpdateCacheBankEditorEvents(EditorBankRef bankRef)
{
//load the bank
FMOD.Studio.Bank bank;
bankRef.LoadResult = EditorUtils.System.loadBankFile(bankRef.Path, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out bank);

        if (bankRef.LoadResult == FMOD.RESULT.ERR_EVENT_ALREADY_LOADED)
        {
            EditorUtils.System.getBank(bankRef.Name, out bank);
            bank.unload();
            bankRef.LoadResult = EditorUtils.System.loadBankFile(bankRef.Path, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out bank);
        }

        if (bankRef.LoadResult == FMOD.RESULT.OK)
        {
            // Get studio path
            string studioPath;
            bank.getPath(out studioPath);
            bankRef.SetStudioPath(studioPath);

            // Update global parameter list for each bank
            FMOD.Studio.PARAMETER_DESCRIPTION[] parameterDescriptions;
            var result = EditorUtils.System.getParameterDescriptionList(out parameterDescriptions);
            if (result == FMOD.RESULT.OK)
            {
                for (int i = 0; i < parameterDescriptions.Length; i++)
                {
                    FMOD.Studio.PARAMETER_DESCRIPTION param = parameterDescriptions[i];
                    if ((param.flags & FMOD.Studio.PARAMETER_FLAGS.GLOBAL) == FMOD.Studio.PARAMETER_FLAGS.GLOBAL)
                    {
                        EditorParamRef paramRef = eventCache.EditorParameters.Find((x) =>
                            (param.id.data1 == x.ID.data1 && param.id.data2 == x.ID.data2));
                        if (paramRef == null)
                        {
                            paramRef = ScriptableObject.CreateInstance<EditorParamRef>();
                            AssetDatabase.AddObjectToAsset(paramRef, eventCache);
                            AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(paramRef));
                            eventCache.EditorParameters.Add(paramRef);
                            paramRef.ID = param.id;
                        }
                        paramRef.Name = param.name;
                        paramRef.name = "parameter:/" + param.name;
                        paramRef.Min = param.minimum;
                        paramRef.Max = param.maximum;
                        paramRef.Default = param.defaultvalue;
                        paramRef.Exists = true;
                    }
                }
            }
            bank.unload();
        }
        else
        {
            Debug.LogError(string.Format("FMOD Studio: Unable to load {0}: {1}", bankRef.Name, FMOD.Error.String(bankRef.LoadResult)));
            eventCache.StringsBankWriteTime = DateTime.MinValue;
        }
    }

If possible I would like to know of my solution is a valid one and that I can safely keep this inside or project.
Ideally this wouldn’t be an issue of course and will hopefully be fixed in the official plugin soon.

1 Like

Thank you very much for the incredibly detailed bug report! We have implemented a fix and it should be available in the next Unity integration upgrade.

Hi @richard_simms, we’ve encountered the same bug @GlowfishInteractive describes (thank you for the detailed description of the bug and the proposed solution!), in 2.01.09. Is the fix supposed to be implemented in this version, or would it be for the next one?

Thank you for your help

Hey @Florian_Vltmn it should be in 2.01.10 but I did received the fix that has been implemented via mail.

Here is what is in the latest update (incase you can’t update)

// Update events from this bank if it has been modified,
// or it is a master bank (so that we get any global parameters)
if (bankRef.LastModified != bankFileInfo.LastWriteTime
|| masterBankFileNames.Contains(Path.GetFileName(bankFileName)))
{
bankRef.LastModified = bankFileInfo.LastWriteTime;
UpdateCacheBank(bankRef);
}

1 Like

Thank you for the information! You can imagine how glad I was to discover the exact bug I was having described with such detail. :slightly_smiling_face: