Rasagar/Library/PackageCache/com.unity.cinemachine/Samples~/Cinemachine Example Scenes/Shared/Scripts/InvokeEventFromInspector.cs
2024-08-26 23:07:20 +03:00

32 lines
794 B
C#

using UnityEngine;
using UnityEngine.Events;
#if UNITY_EDITOR
using UnityEditor;
using Cinemachine.Editor;
#endif
namespace Cinemachine.Examples
{
public class InvokeEventFromInspector : MonoBehaviour
{
public UnityEvent Event = new UnityEvent();
public void Invoke() { Event.Invoke(); }
}
#if UNITY_EDITOR
[CustomEditor(typeof(InvokeEventFromInspector))]
public class GenerateEventEditor : BaseEditor<InvokeEventFromInspector>
{
public override void OnInspectorGUI()
{
BeginInspector();
Rect rect = EditorGUILayout.GetControlRect(true);
if (GUI.Button(rect, "Invoke", "Button"))
Target.Invoke();
DrawRemainingPropertiesInInspector();
}
}
#endif
}