Beispiel #1
0
            private void SetScrollAreaEnabled(bool enabled)
            {
                _scrollArea.enabled = enabled;

                if (!enabled)
                {
                    RectTransformUtils.SetY(_scrollArea.content, 0f);
                }

                RectMask2D mask = _scrollArea.viewport.GetComponent <RectMask2D>();

                if (mask != null)
                {
                    mask.enabled = enabled;
                }
            }
Beispiel #2
0
            private static void OnInputToggleMenu(InputAction.CallbackContext context)
            {
                if (_visuals == null)
                {
                    GameObject prefab = Resources.Load <GameObject>("Debug Menu");
                    _visuals = GameObject.Instantiate(prefab).GetComponent <DebugMenuVisuals>();
                    GameObject.DontDestroyOnLoad(_visuals.gameObject);

                    //Create items
                    GameObject itemPrefab = _visuals._items[0].gameObject;

                    TextMeshProUGUI[] items = new TextMeshProUGUI[_visuals._maxItems];
                    items[0] = _visuals._items[0];

                    float y = 0f;

                    for (int i = 1; i < items.Length; i++)
                    {
                        items[i] = GameObject.Instantiate(itemPrefab, itemPrefab.transform.parent, false).GetComponent <TextMeshProUGUI>();
                        y       -= RectTransformUtils.GetHeight(items[i].rectTransform);
                        RectTransformUtils.SetY(items[i].rectTransform, y);
                    }

                    _visuals._items = items;

                    _visuals.gameObject.SetActive(false);
                    _currentMenu      = _rootMenu;
                    _currentItemIndex = _currentMenu._items.Count - 1;
                }

                if (_visuals.gameObject.activeSelf)
                {
                    _visuals.gameObject.SetActive(false);
                }
                else
                {
                    _visuals.gameObject.SetActive(true);
                    RefreshMenu();
                }
            }