I try to invoke a other UnityEvent by pressing a button but it looks like it’s not working for some reason
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.UI.Extensions;
using System.Collections.Generic;
using UnityEngine.Events;
public class MyClass: MonoBehaviour {
public gameobject obj;
Start() {
button.GetComponent<Button>().onClick.AddListener(DoIt);
}
public void DoIt(){
Debug.Log("I'm doing it"!);
obj.GetComponent<Script>().MyUnityEvent.Invoke();
}
}
In “MyUnityEvent” is just another debug.log but i don’t get any response or error code.
Delegate is not an option because every object have different event’s to call.
What’s wrong here? Can somebody help? thanks ^^