28 lines
794 B
C#
28 lines
794 B
C#
|
|
using System;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Linq;
|
||
|
|
using UnityEngine;
|
||
|
|
using UnityEngine.UI;
|
||
|
|
using UVC.Extension;
|
||
|
|
|
||
|
|
namespace Simulator.UI
|
||
|
|
{
|
||
|
|
public class ControlButtons : MonoBehaviour
|
||
|
|
{
|
||
|
|
private Dictionary<string, Button> buttons = new Dictionary<string, Button>();
|
||
|
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||
|
|
public void Init()
|
||
|
|
{
|
||
|
|
var buttons = transform.GetChildren<Button>();
|
||
|
|
foreach (var button in buttons)
|
||
|
|
{
|
||
|
|
this.buttons.Add(button.name, button);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public void SetClickAction(string name, Action action)
|
||
|
|
{
|
||
|
|
buttons[name].onClick.AddListener(() => action.Invoke());
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|