1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Sirenix.OdinInspector;
- using KairoEngine.Core.GameActions;
- using KairoEngine.UI.InteractionHandler;
- namespace KairoEngine.UI
- {
- /// <summary>
- /// Set GameActions to be run when a UI Menu buttom has been clicked
- /// </summary>
- [HideMonoScript]
- public class MenuController : MonoBehaviour, IClickHandler
- {
- [InlineProperty, HideLabel] public GameActionContext context = new GameActionContext();
-
- [OnCollectionChanged("SetupActions"), PropertySpace(4,0), ListDrawerSettings(DraggableItems = false)]
- public List<MenuAction> menuActions = new List<MenuAction>();
- public void OnClick(string title)
- {
- for (int i = 0; i < menuActions.Count; i++)
- {
- if(menuActions[i].title == title) menuActions[i].Execute();
- }
- }
- private void SetupActions()
- {
- for (int i = 0; i < menuActions.Count; i++)
- {
- if(menuActions[i] != null)
- {
- if(menuActions[i].actionsController != null)
- {
- menuActions[i].actionsController.context = context;
- }
- }
-
- }
- }
- }
- }
|