using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using Sirenix.OdinInspector; using KairoEngine.UI.InteractionHandler; namespace KairoEngine.UI.Encyclopedia { [HideMonoScript] public class EncyclopediaUi : MonoBehaviour { public EncyclopediaController controller; public GameObject menuGameObject; public GameObject subMenuGameObject; public GameObject viewsGameObject; public Transform menuContainer; public Transform subMenuContainer; public bool createOnStart = true; public bool showDebug = false; public List views; private List menuButtonSelection; private List subMenuButtonSelection; private int menuIndex = -1; private int subMenuIndex = -1; private int currentMenuIndex = -1; private int currentSubMenuIndex = -1; private void Start() { if(menuGameObject == null) Debug.LogError("Missing Menu GameObject in EncyclopediaUi", this.gameObject); if(subMenuGameObject == null) Debug.LogError("Missing submenu GameObject in EncyclopediaUi", this.gameObject); if(viewsGameObject == null) Debug.LogError("Missing views GameObject in EncyclopediaUi", this.gameObject); if(createOnStart) Populate(); } private void Update() { } [Button("Show Submenu"), ButtonGroup("EditorActions")] public void ShowSubmenu() => subMenuGameObject.SetActive(true); [Button("Hide Submenu"), ButtonGroup("EditorActions")] public void HideSubmenu() => subMenuGameObject.SetActive(false); public void Populate() { if(showDebug) Debug.Log("Creating Encyclopedia UI Element"); menuIndex = controller.menuIndex; subMenuIndex = controller.subMenuIndex; currentMenuIndex = controller.menuIndex; currentSubMenuIndex = controller.subMenuIndex; CreateMenu(); CreateSubMenu(); ShowArticle(); } public void CreateMenu() { if(controller == null || menuContainer == null) return; menuButtonSelection = new List(); int counter = 0; //if(showDebug) Debug.Log($"Destroying {oldButtons.Length} menu buttons"); Button[] oldButtons = menuContainer.GetComponentsInChildren