Cannot convert from 'FMODUnity.EventReference' to 'string'

Hi. I’ve been upgrading to the 2.02.04 version of the integration plugin. All my event references were set up this way :

[SerializeField][EventRef] private string eventName;

After upgrading the plugin I had the following message under my events in the inspector :

[EventRef] is obsolete - use the EventReference type instead

which I did. For most of my events everything works fine but I had this issue lately and I don’t know what to do in order to make it work :

I have several events that are called by a PlayOneShotAttached() function. Here is my how it is called basically :

[SerializeField] EventReference eventName;
private void Update()
{
  if(aConditionIsMet)
    RuntimeManager.PlayOneShotAttached(eventName, targetObject);
}

After saving, I had the following error in my log :

error CS1503: Argument 1: cannot convert from ‘FMODUnity.EventReference’ to ‘string’

Should I be able to use PlayOneShotAttached() or did I miss something new that doesn’t require a string ?

Try calling PlayOneShotAttached with the event reference’s guid:

RuntimeManager.PlayOneShotAttached(eventName.Guid, targetObject);

That does make updating to 2.02.xx needlessly complicated, I will pass this onto the dev team and see if we can get an overload of PlayOneShotAttached for the EventReference type or something similar.

1 Like

Hi Jeff. Thanks for your answer ! Once you told me, I didn’t find this that complicated, but it could definitely being added to the documentation. Unless I missed it (or searched in the wrong place) I did not see any mention of this change : https://www.fmod.com/resources/documentation-api?version=2.02&page=welcome-whats-new-202.html#api-differences_1

This is definitely just something that was missed when we moved over to EventReferences- it looks like PlayOneShot got an EventReference overload but PlayOneShotAttached did not, so we’ll be adding one in a future release. Thank you for bringing this to our attention!

1 Like