예제 #1
0
        public static bool IsMouseOverUi()
        {
            if (DragWithMouse.beingDragged != null)
            {
                return(true);
            }
            if (!EventSystem.current.IsPointerOverGameObject())
            {
                return(false);
            }
            PointerEventData pointerEventData = new PointerEventData(EventSystem.current);

            pointerEventData.position = AppInput.MousePosition;
            List <RaycastResult> raycastResult = new List <RaycastResult>();

            EventSystem.current.RaycastAll(pointerEventData, raycastResult);
            for (int i = 0; i < raycastResult.Count; ++i)
            {
                UiClick uiClick = raycastResult[i].gameObject.GetComponent <UiClick>();
                if (uiClick && uiClick.ignoreClicksOnThisElement)
                {
                    raycastResult.RemoveAt(i--);
                }
            }
            //if (raycastResult.Count > 0) {
            //	Debug.Log(raycastResult.JoinToString(", ", r => r.gameObject.name));
            //}
            return(raycastResult.Count > 0);
        }
예제 #2
0
        void Start()
        {
            Button b = GetComponent <Button>();

            b.onClick.AddListener(DoActivateTrigger);
            if (uiToggleClose != null)
            {
                uiToggleClose.onClick.AddListener(DoActivateTrigger);
            }
            if (uiStartsHidden || clickMeAfterStart)
            {
                GameClock.Delay(0, () => {
                    if (uiStartsHidden)
                    {
                        uiToControlVisibility.SetActive(false);
                    }
                    if (clickMeAfterStart)
                    {
                        //Debug.Log("first click " + b);
                        UiClick.Click(b);
                    }
                });
            }
        }