Last active
November 27, 2016 13:14
-
-
Save dykarohora/d403fdd8b05cea5bf7bfa467e5bd4d14 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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