- Home /
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;
}
'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?
Answer by hexagonius · Nov 22, 2016 at 08:56 PM
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)
Your answer
Follow this Question
Related Questions
How to select an int/float variable from another script in the inspector? 2 Answers
How to access the persistent listener gameobjects on a button? 1 Answer
Argument 1: cannot convert from 'method group' to 'UnityAction' 1 Answer
Does calling Destroy() on a GameObject/MonoBehavior drop references to any event listeners? 1 Answer