using System;
using System.Collections;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.Serialization;
namespace UnityEngine.UI
{
// Button that's meant to work with mouse or touch-based devices.
[AddComponentMenu("UI/Button", 30)]
public class Button : Selectable, IPointerClickHandler, ISubmitHandler
{
[Serializable]
///
/// Function definition for a button click event.
///
public class ButtonClickedEvent : UnityEvent {}
// Event delegates triggered on click.
[FormerlySerializedAs("onClick")]
[SerializeField]
private ButtonClickedEvent m_OnClick = new ButtonClickedEvent();
protected Button()
{}
///
/// UnityEvent that is triggered when the button is pressed.
/// Note: Triggered on MouseUp after MouseDown on the same object.
///
///
///
/// using UnityEngine;
/// using UnityEngine.UI;
/// using System.Collections;
///
/// public class ClickExample : MonoBehaviour
/// {
/// public Button yourButton;
///
/// void Start()
/// {
/// Button btn = yourButton.GetComponent
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.Serialization;
using System;
namespace MyEvent
{
public class MyCompotent : MonoBehaviour {
[Serializable]
public class MyCompontentEvent:UnityEvent{ }
[FormerlySerializedAs("MyEvent")]
[SerializeField]
private MyCompontentEvent myEvent = new MyCompontentEvent();
public MyCompontentEvent MyEvent { get { return myEvent; }set { myEvent = value; } }
//执行绑定的事件
public void ExcuteEvent()
{
MyEvent.Invoke();
}
}
}
我们将脚本挂到空物体上,效果如下:
使用方法如下例子:
我们自己写一个步骤设置器,代码如下:
namespace MyEvent
{
public class StepControl : MyCompotent
{
public string Name;
public int Index;
private void Start()
{
//设置名字
//设置Index
//去做每一步应该设置得事情
ExcuteEvent();
}
}
}