Esempio n. 1
0
        public RectTransform MenuCreateRect(MenuBehavior _menu, string _name, Vector2 _position)
        {
            RectTransform uiRect = MenuCreateRect(_menu, _name);

            SetUiRect(uiRect, _position);

            return(uiRect);
        }
Esempio n. 2
0
 public void AddMenuWithButtons(MenuBehavior _menu, params UnityAction[] _buttonActions)
 {
     if (!allMenus.Contains(_menu))
     {
         allMenus.Add(_menu);
         ((MenuWithButtons)_menu).InitMenu(_buttonActions);
     }
 }
Esempio n. 3
0
        public InputField MenuForceAddInputField(MenuBehavior _menu, string _name, Vector2 _position)
        {
            RectTransform uiRect = MenuCreateRect(_menu, _name, _position);

            InputField input = uiRect.gameObject.AddComponent <InputField>();

            return(input);
        }
Esempio n. 4
0
        public Button MenuForceAddButton(MenuBehavior _menu, string _buttonName, Sprite _buttonSprite, Vector2 _position, UnityAction _actionFunction)
        {
            Image buttonImage = MenuAddImage(_menu, _buttonName, _buttonSprite, _position);

            Button button = buttonImage.gameObject.AddComponent <Button>();

            button.onClick.RemoveAllListeners();
            button.onClick.AddListener(_actionFunction);

            return(button);
        }
Esempio n. 5
0
        public RectTransform MenuCreateRect(MenuBehavior _menu, string _name)
        {
            GameObject uiObj = new GameObject(_name);

            RectTransform uiRect = uiObj.AddComponent <RectTransform>();

            uiObj.transform.SetParent(_menu.transform);

            uiObj.AddComponent <CanvasRenderer>();

            return(uiRect);
        }
Esempio n. 6
0
        public InputField MenuAddInputField(MenuBehavior _menu, string _name, Vector2 _position)
        {
            InputField[] inputFields = _menu.GetComponentsInChildren <InputField>(true);

            foreach (InputField inf in inputFields)
            {
                if (inf.name == _name)
                {
                    return(inf);
                }
            }
            return(MenuForceAddInputField(_menu, _name, _position));
        }
Esempio n. 7
0
        public Text MenuAddText(MenuBehavior _menu, string _name, Vector2 _position, string _context)
        {
            Text[] texts = _menu.GetComponentsInChildren <Text>(true);

            foreach (Text txt in texts)
            {
                if (txt.name == _name)
                {
                    return(txt);
                }
            }

            return(MenuForceAddText(_menu, _name, _position, _context));
        }
Esempio n. 8
0
        public Button MenuAddButton(MenuBehavior _menu, string _name, Sprite _sprite, Vector2 _position, UnityAction _action)
        {
            Button[] buttons = _menu.GetComponentsInChildren <Button>(true);

            foreach (Button btn in buttons)
            {
                if (btn.name == _name)
                {
                    return(btn);
                }
            }

            return(MenuForceAddButton(_menu, _name, _sprite, _position, _action));
        }
Esempio n. 9
0
        public Image MenuAddImage(MenuBehavior _menu, string _imageName, Sprite _imageSprite, Vector2 _position)
        {
            Image[] images = _menu.GetComponentsInChildren <Image>(true);

            foreach (Image img in images)
            {
                if (img.name == _imageName)
                {
                    return(img);
                }
            }

            return(MenuForceAddImage(_menu, _imageName, _imageSprite, _position));
        }
Esempio n. 10
0
        public Text MenuForceAddText(MenuBehavior _menu, string _name, Vector2 _position, string _context)
        {
            RectTransform uiRect = MenuCreateRect(_menu, _name, _position);

            Text uiText = uiRect.gameObject.AddComponent <Text>();

            uiText.text = _context;

            uiText.alignment     = TextAnchor.MiddleCenter;
            uiText.fontSize      = 100;
            uiText.color         = Color.black;
            uiText.font          = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font;
            uiText.raycastTarget = false;

            return(uiText);
        }
Esempio n. 11
0
        public Image MenuForceAddImage(MenuBehavior _menu, string _imageName, Sprite _imageSprite, Vector2 _position)
        {
            RectTransform uiRect = MenuCreateRect(_menu, _imageName);

            Image buttonImage = uiRect.gameObject.AddComponent <Image>();

            if (_imageSprite != null)
            {
                SetUiRect(uiRect, _position);

                buttonImage.sprite = _imageSprite;
                buttonImage.SetNativeSize();
            }
            else
            {
                SetExpandedUiRect(uiRect, Vector3.zero);
                buttonImage.color = new Color(1.0f, 1.0f, 1.0f, 0.0f);
            }

            return(buttonImage);
        }
Esempio n. 12
0
 public Image MenuForceAddImage(MenuBehavior _menu, string _imageName, Vector2 _position)
 {
     return(MenuForceAddImage(_menu, _imageName, GetSprite(_imageName), _position));
 }
Esempio n. 13
0
 public Button MenuAddButton(MenuBehavior _menu, UnityAction _actionFunction)
 {
     return(MenuAddButton(_menu, "BUTTON", null, Vector3.zero, _actionFunction));
 }
Esempio n. 14
0
 public Button MenuAddButton(MenuBehavior _menu, string _buttonName, Vector2 _position, UnityAction _actionFunction)
 {
     return(MenuAddButton(_menu, _buttonName, GetSprite(_buttonName), _position, _actionFunction));
 }