Skip to content

Instantly share code, notes, and snippets.

@timrodz
Last active September 23, 2021 03:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timrodz/21e7339f8dab8d3a0ac532b8012f274f to your computer and use it in GitHub Desktop.
Save timrodz/21e7339f8dab8d3a0ac532b8012f274f to your computer and use it in GitHub Desktop.
Delegate Tutorial Step 3
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EventController : MonoBehaviour
{
// The delegate is our signature-- Define your parameters between the parentheses
public delegate void OnMessageUpdateRequestDelegate(string _message);
// This will be the delegate we're subscribing towards
public static OnMessageUpdateRequestDelegate OnMessageUpdateRequest;
public static void Event_OnMessageUpdateRequest(string _message)
{
Debug.LogFormat("-- EventController // Received a request to update message: {0}", _message);
OnMessageUpdateRequest(_message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment