How can I get the Transform from an Object (target of UnityEvent)?

Hello!

I’m trying to draw a gizmo line from the current object to the target object of each of its UnityEvents. I’ve been able to figure out that the target of a UnityEvent is an ‘object’ (not a GameObject).

How can I get a reference to the Transform component of these objects?

I’m able to get a reference to the object correctly, and I can confirm this with Debug Logs. I suspect I need to do something using GetType, but I’ve been unable to figure out what, or how I should write my code.

IEnumerator DrawHelperLines () {
		Gizmos.color = Color.yellow;
		int i = 0;
		foreach (ScriptedSequenceEvent currentEvent in events) {
			object obj = currentEvent.scriptedEvent.GetPersistentTarget (0);
//			~~~ What goes here??? ~~~
			Transform target;
			Gizmos.DrawLine (transform.position, target.position);
			i++;
		}		
		yield break;
	}

Thanks in advance :slight_smile:

GameObject gameObject = obj as GameObject;
Transform target = gameObject.transform;