private void AddPanelsToSettings()
        {
            Transform headerArea = transform.Find("SafeArea").Find("HeaderContainer").Find("Header (JUICED)");

            HGHeaderNavigationController navigationController = GetComponent <HGHeaderNavigationController>();

            GameObject modOptionsHeaderButton = Instantiate(_panel.ModOptionsHeaderButton, headerArea);

            modOptionsHeaderButton.name = "GenericHeaderButton (Mod Options)";
            modOptionsHeaderButton.GetComponentInChildren <LanguageTextMeshController>().token = LanguageTokens.HeaderToken;
            modOptionsHeaderButton.GetComponentInChildren <HGButton>().onClick.RemoveAllListeners();
            modOptionsHeaderButton.GetComponentInChildren <HGButton>().onClick.AddListener(delegate()
            {
                navigationController.ChooseHeaderByButton(modOptionsHeaderButton.GetComponentInChildren <HGButton>());
            });

            List <HGHeaderNavigationController.Header> headers = GetComponent <HGHeaderNavigationController>().headers.ToList();

            modOptionsHeaderButton.GetComponentInChildren <HGTextMeshProUGUI>().SetText("MOD OPTIONS");

            HGHeaderNavigationController.Header header = new HGHeaderNavigationController.Header
            {
                headerButton  = modOptionsHeaderButton.GetComponent <HGButton>(),
                headerName    = "Mod Options",
                tmpHeaderText = modOptionsHeaderButton.GetComponentInChildren <HGTextMeshProUGUI>(),
                headerRoot    = _panel.Canvas
            };

            headers.Add(header);

            GetComponent <HGHeaderNavigationController>().headers = headers.ToArray();

            transform.Find("SafeArea").Find("HeaderContainer").Find("Header (JUICED)").Find("GenericGlyph (Right)").SetAsLastSibling();
        }
        protected override void Start()
        {
            base.Start();

            if (nameLabel)
            {
                nameLabel.token = token;
            }

            if (!Mopc)
            {
                Mopc = GetComponentInParent <ModOptionPanelController>();
            }

            //_icon = GetComponentInChildren<UnityEngine.UI.Image>();

            onClick.AddListener(delegate
            {
                navigationController.ChooseHeaderByButton(this);

                Mopc.LoadModOptionsFromOptionCollection(modGuid);
            });
        }
        internal void LoadModOptionsFromOptionCollection(string modGuid)
        {
            OptionCollection collection = ModSettingsManager.OptionCollection[modGuid];

            GameObject categoriesObject = _panel.CategoryHeader.transform.Find("Scroll View").Find("Viewport").Find("Categories (JUICED)").gameObject;

            HGHeaderNavigationController navigationController = categoriesObject.GetComponent <HGHeaderNavigationController>();

            CategoryScrollRect categoryScrollRect = _panel.CategoryHeader.GetComponentInChildren <CategoryScrollRect>();

            if (_panel.CategoryHeader.activeSelf || _panel.ModOptionsPanel.activeSelf || _panel.ModOptionsDescriptionPanel.activeSelf || categoryScrollRect.categoryButtons.Count > 0)
            {
                UnloadExistingCategoryButtons();
            }

            if (_panel.ModDescriptionPanel.activeSelf || !_panel.CategoryHeader.activeSelf || !_panel.ModOptionsPanel.activeSelf || !_panel.ModOptionsDescriptionPanel.activeSelf)
            {
                _panel.ModDescriptionPanel.GetComponentInChildren <HGTextMeshProUGUI>().SetText("");

                _panel.ModDescriptionPanel.SetActive(false);
                _panel.CategoryHeader.SetActive(true);
                _panel.ModOptionsPanel.SetActive(true);
                _panel.ModOptionsDescriptionPanel.SetActive(true);
            }

            List <HGHeaderNavigationController.Header> headers = new List <HGHeaderNavigationController.Header>();

            navigationController.currentHeaderIndex = 0;

            categoryScrollRect.Categories = collection.CategoryCount;

            _panel.CategoryLeftButton.SetActive(true);
            _panel.CategoryLeftButton.transform.SetSiblingIndex(_panel.CategoryPageIndicators.transform.GetSiblingIndex() - 1);

            for (int i = 0; i < collection.CategoryCount; i++)
            {
                GameObject newCategoryButton = Instantiate(_panel.ModOptionsHeaderButton, categoriesObject.transform);

                LayoutElement le = newCategoryButton.AddComponent <LayoutElement>();

                le.preferredWidth = 200;

                newCategoryButton.GetComponentInChildren <LanguageTextMeshController>().token = collection[i].NameToken;
                newCategoryButton.GetComponentInChildren <HGTextMeshProUGUI>().SetText(collection[i].name);
                newCategoryButton.GetComponentInChildren <HGButton>().onClick.RemoveAllListeners();

                var categoryIndex = i;

                newCategoryButton.GetComponentInChildren <HGButton>().onClick.AddListener(delegate
                {
                    navigationController.ChooseHeaderByButton(newCategoryButton.GetComponentInChildren <HGButton>());

                    LoadOptionListFromCategory(modGuid, categoryIndex, headers.Count);
                });

                newCategoryButton.name = $"Category Button, {collection[i].name}";
                newCategoryButton.SetActive(true);

                HGHeaderNavigationController.Header header = new HGHeaderNavigationController.Header
                {
                    headerButton  = newCategoryButton.GetComponent <HGButton>(),
                    headerName    = $"Category Button, {collection[i].name}",
                    tmpHeaderText = newCategoryButton.GetComponentInChildren <HGTextMeshProUGUI>(),
                    headerRoot    = null
                };

                categoryScrollRect.categoryButtons.Add(newCategoryButton);

                headers.Add(header);
            }
            categoryScrollRect.SetPage(0);
            categoryScrollRect.FixExtra();

            navigationController.headers = headers.ToArray();
            navigationController.InvokeMethod("RebuildHeaders");

            _panel.CategoryRightButton.SetActive(true);
            _panel.CategoryRightButton.transform.SetAsLastSibling();

            LoadOptionListFromCategory(collection.ModGuid, navigationController.currentHeaderIndex, navigationController.headers.Length);
        }