U
U
Uncle Bogdan2021-01-30 14:24:41
C++ / C#
Uncle Bogdan, 2021-01-30 14:24:41

Unable to call Event. c#, unity. What's the catch?

Code + error.

using UnityEngine;

public class Gun
{
    public delegate void Shoot();
    public event Shoot ShootEvent;
    
}

public class GunManager : MonoBehaviour
{
    public Gun SmallGun;
    private void Start()
    {
        SmallGun.ShootEvent += First;
        SmallGun.ShootEvent += Two;
        if(SmallGun.ShootEvent() != null)
        {
            SmallGun.ShootEvent();
        }
    }

    public void First()
    {
        Debug.Log("Jojo");
    }
    public void Two()
    {
        Debug.Log("Jojo2");
    }
}

601541d488094326907414.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question