Esempio n. 1
0
    public void CreateRightClickMenu(ControllableUI controllableUI)
    {
        if (_rightClickMenuInstantiated)
        {
            Destroy(_rightClickMenu);
            _rightClickMenuInstantiated = false;
        }

        _rightClickMenu = Instantiate(RightClickMenu, _rootCanvas.transform);

        _rightClickMenu.transform.GetChild(0).GetComponent <Button>().onClick.AddListener(controllableUI.CopyAddressToClipboard);
        _rightClickMenu.transform.GetChild(0).GetComponent <Button>().onClick.AddListener(() => { Destroy(_rightClickMenu); });


        var rectTransform = _rightClickMenu.GetComponent <RectTransform>();

        rectTransform.pivot     = new Vector2(0.0f, 0.5f);
        rectTransform.anchorMin = new Vector2(0.0f, 0.5f);
        rectTransform.anchorMax = new Vector2(0.0f, 0.5f);

        _rightClickMenu.transform.position = Input.mousePosition;

        /*
         * Debug.Log(rectTransform.anchoredPosition.x);
         * if (rectTransform.anchoredPosition.x < 0)
         *  rectTransform.anchoredPosition = new Vector2(0.0f, rectTransform.anchoredPosition.y);
         */
        _rightClickMenuInstantiated = true;
        _skipNextButton             = true;
    }
Esempio n. 2
0
 public void AddUIElement(ControllableUI newElement)
 {
     if (_uiElements == null)
     {
         _uiElements = new List <ControllableUI>();
     }
     _uiElements.Add(newElement);
 }