How to get argument values from persistent listener of UnityEvent

Hello, I’m trying to find a way to access value of argument passed to Persistent Listener added to UnityEvent using inspector.

Example:

using UnityEngine;
using UnityEngine.Events;

public class EventTester : MonoBehaviour {
	public UnityEvent ev;
}

82678-unityeventtest.png

‘Ev’ contains one Persistent Listener, its target is some GameObject, called method is SetActive, argument passed to method is true, what I’m trying to get is ‘true’ passed to SetActive.

This value is saved in scene file like this:

ev:
    m_PersistentCalls:
      m_Calls:
      - m_Target: {fileID: 2030264660}
        m_MethodName: SetActive
        m_Mode: 6
        m_Arguments:
          m_ObjectArgument: {fileID: 0}
          m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
          m_IntArgument: 0
          m_FloatArgument: 0
          m_StringArgument: 
          m_BoolArgument: 1
        m_CallState: 2
    m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine, Version=0.0.0.0, Culture=neutral,
      PublicKeyToken=null

but I can’t find any way to get this value without parsing such file.

Is there any way to, for example using reflection, get access to m_Calls array?

you’re pretty much out of luck here. the only class handling those is UnityEventTools and it’s only capable of adding removing and stuff, but no get or anything. you could programmatically create them yourself or just remember the parameter somewhere (bad I know)

You can get all values from SerializedObject class :wink: