123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using Sirenix.OdinInspector;
- using KairoEngine.UI.InteractionHandler;
- namespace KairoEngine.UI.Encyclopedia
- {
- [HideMonoScript]
- public class EncyclopediaController : MonoBehaviour, IClickHandler
- {
- [ShowInInspector, HorizontalGroup("IndexLine", 0.7f), LabelText("Index")] public int menuIndex;
- [ShowInInspector, HorizontalGroup("IndexLine", 0.3f), HideLabel] public int subMenuIndex;
- public EncyclopediaUi encyclopediaUi;
- public GameObject categoryButtomPrefab;
- public List<EncyclopediaCategory> categories = new List<EncyclopediaCategory>();
- [Button("Build Menu"), ButtonGroup("Buttons")]
- public void BuildMenu()
- {
- if(encyclopediaUi != null) encyclopediaUi.Populate();
- else Debug.LogError("Missing Encyclopedia UI in Encyclopedia Controller", this.gameObject);
- }
- public void OnClick(string id)
- {
- for (int i = 0; i < categories.Count; i++)
- {
- if(id == categories[i].id)
- {
- menuIndex = i;
- Navigate();
- return;
- }
- var articles = categories[i].GetArticles();
- for (int a = 0; a < articles.Count; a++)
- {
- if(id == articles[a].id)
- {
- menuIndex = i;
- subMenuIndex = a;
- Navigate();
- return;
- }
- }
- }
- }
- [Button("Navigate"), ButtonGroup("Buttons")]
- public void Navigate()
- {
- if(encyclopediaUi != null) encyclopediaUi.Navigate();
- }
- }
- }
|