Advertisement
Guest User

Unity events in inspector example

a guest
Aug 31st, 2014
1,429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.56 KB | None | 0 0
  1. using System;
  2. using System.Reflection;
  3. using UnityEngine;
  4. using System.Collections;
  5. using UnityEngine.EventSystems;
  6. using UnityEngine.Events;
  7.  
  8. public class MyEventObject : MonoBehaviour, IEventSystemHandler
  9. {
  10.     [RenamedSerializedData("onPress")]
  11.     [SerializeField]
  12.     private ButtonClickedEvent m_OnClick = new ButtonClickedEvent();
  13.  
  14.     public void Start()
  15.     {
  16.     ButtonPressed();
  17.     }
  18.  
  19.     private void ButtonPressed()
  20.     {
  21.         m_OnClick.Invoke();
  22.     }
  23.  
  24.     [Serializable]
  25.     public class ButtonClickedEvent : UnityEvent
  26.     {}
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement