Esempio n. 1
0
        internal void Display(Vector3 position)
        {
            if (CurrentContextMenu != null)
            {
                CurrentContextMenu.Hide();
            }

            InitialiseOptions();
            LockToOverlay();

            LayoutRebuilder.ForceRebuildLayoutImmediate(rectTransform);
            position.x = Mathf.Min(position.x, Screen.width - rectTransform.rect.width);
            position.y = Mathf.Min(position.y, Screen.height - rectTransform.rect.height);

            rectTransform.anchorMin        = new Vector2(0, 1);
            rectTransform.anchorMax        = new Vector2(0, 1);
            rectTransform.pivot            = new Vector2(0, 1);
            rectTransform.anchoredPosition = new Vector3(position.x, -position.y, 0);

            var activeBlocker   = OpenTibiaUnity.GameManager.ActiveBlocker;
            var buttonComponent = activeBlocker.GetComponent <Button>();

            if (buttonComponent)
            {
                Destroy(buttonComponent);
            }

            buttonComponent = activeBlocker.gameObject.AddComponent <Button>();
            buttonComponent.onClick.AddListener(Hide);

            CurrentContextMenu = this;
        }
Esempio n. 2
0
        internal void Hide()
        {
            UnlockFromOverlay();
            Destroy(gameObject);

            var activeBlocker   = OpenTibiaUnity.GameManager.ActiveBlocker;
            var buttonComponent = activeBlocker.GetComponent <Button>();

            if (buttonComponent)
            {
                Destroy(buttonComponent);
            }

            CurrentContextMenu = null;
        }