79 lines
1.4 KiB
C#
79 lines
1.4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
|
|
public enum ButtonType
|
|
{
|
|
F1,
|
|
F2,
|
|
F3,
|
|
F4,
|
|
F5,
|
|
F6,
|
|
F7,
|
|
F8,
|
|
F9,
|
|
F10,
|
|
上箭头,
|
|
下箭头,
|
|
左箭头,
|
|
右箭头,
|
|
num1,num2, num3, num4, num5, num6,num7, num8, num9,num0,
|
|
删除,
|
|
退出,
|
|
空格,
|
|
确认,
|
|
上移,下移,
|
|
上翻,下翻,
|
|
电源,
|
|
总电源,
|
|
升降,
|
|
北斗,
|
|
惯性导航,
|
|
综合控制
|
|
}
|
|
|
|
public class ModelBtnManager : MonoBehaviour
|
|
{
|
|
// 所有按钮的控制器
|
|
public ModelButtonController[] modelButtons;
|
|
|
|
// 使用字典来映射按钮类型与其对应的事件
|
|
private Dictionary<ButtonType, UnityEvent> buttonActions = new Dictionary<ButtonType, UnityEvent>();
|
|
|
|
void Start()
|
|
{
|
|
// 初始时可以绑定一些默认事件
|
|
//buttonActions.Add(ButtonType.Button1, new UnityEvent());
|
|
//buttonActions.Add(ButtonType.Button2, new UnityEvent());
|
|
//buttonActions.Add(ButtonType.Button3, new UnityEvent());
|
|
|
|
// 设置按钮事件
|
|
//SetupPanel();
|
|
}
|
|
|
|
|
|
private void Update()
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.F1))
|
|
{
|
|
Debug.Log("F1");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 清除所有按钮事件
|
|
/// </summary>
|
|
public void ClearAllBtnEvent()
|
|
{
|
|
foreach (var btn in modelButtons)
|
|
{
|
|
btn.ClearAllEvent();
|
|
}
|
|
}
|
|
|
|
}
|