Skip to content

Instantly share code, notes, and snippets.

@dykarohora
Last active November 27, 2016 13:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dykarohora/d403fdd8b05cea5bf7bfa467e5bd4d14 to your computer and use it in GitHub Desktop.
Save dykarohora/d403fdd8b05cea5bf7bfa467e5bd4d14 to your computer and use it in GitHub Desktop.
using UnityEngine;
using UnityEngine.EventSystems;
public class SampleEventData : BaseEventData
{
public string SampleStr { get; private set; }
public SampleEventData(EventSystem eventSystem, string sampleStr) : base(eventSystem)
{
SampleStr = sampleStr;
}
}
public interface ISampleHandler : IEventSystemHandler
{
void OnSampleCode(SampleEventData eventData);
}
public class SampleInputModule : BaseInputModule
{
public GameObject TargetObject { get; set; }
public override void Process()
{
if (TargetObject != null)
ExecuteEvents.Execute<ISampleHandler>(TargetObject, new SampleEventData(eventSystem, "sample data"),
(handler, eventData) => handler.OnSampleCode(ExecuteEvents.ValidateEventData<SampleEventData>(eventData)));
}
}
public class SampleEventMB : MonoBehaviour, ISampleHandler
{
public void OnSampleCode(SampleEventData eventData)
{
Debug.Log(eventData.SampleStr);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment