Exemple #1
0
        /// <summary>
        /// 判断是否在区域内
        /// </summary>
        /// <param name="handIndex"></param>
        /// <returns></returns>
        bool IsAreaContains(int handIndex)
        {
            if (panelType == PanelType.UI)
            {
                return(KGUI_Utility.IsAreaContains(transform, handIndex) || OtherRectAreaContains(handIndex));
            }
            else
            {
                Vector3 screenPoint = MUtility.UIWorldToScreenPoint(transform.position);

                return(KGUI_Utility.IsAreaContains(screenPoint, panelSize, handIndex) || OtherRectAreaContains(handIndex));
            }
        }
Exemple #2
0
        void OnButtonRelease(int handIndex)
        {
            if (!enabled)
            {
                return;
            }

            //如果当前手的值不等于-1,并且释放时,跟当前手不符,则直接跳过
            if (this.handIndex != -1 && this.handIndex != handIndex)
            {
                return;
            }

            handIndex = -1;

            GameObject    panelObject   = new GameObject("panel");
            RectTransform rectTransform = panelObject.AddComponent <RectTransform>();

            rectTransform.SetParent(transform);
            rectTransform.localScale    = Vector3.one;
            rectTransform.localPosition = Vector3.zero;

            var parentRect = GetComponent <RectTransform>();

            var templateRect = Template.GetComponent <RectTransform>();

            rectTransform.sizeDelta = new Vector2(parentRect.sizeDelta.x, parentRect.sizeDelta.y + templateRect.sizeDelta.y);

            rectTransform.localPosition = new Vector3(0, -(rectTransform.sizeDelta.y / 2 - parentRect.sizeDelta.y / 2), 0);

            if (!KGUI_Utility.IsAreaContains(rectTransform, handIndex))
            {
                Template.SetActive(false);
            }

            DestroyImmediate(panelObject);
        }
Exemple #3
0
        /// <summary>
        /// 判断其他集合区域是否在范围内
        /// </summary>
        /// <returns></returns>
        bool OtherRectAreaContains(int hand)
        {
            if (panelType == PanelType.UI)
            {
                if (OtherRects == null)
                {
                    return(false);
                }

                foreach (var item in OtherRects)
                {
                    if (KGUI_Utility.IsAreaContains(item, hand))
                    {
                        return(true);//如果存在,就可以直接返回了
                    }
                }
            }
            else
            {
                if (OtherSizes == null)
                {
                    return(false);
                }

                foreach (var item in OtherSizes)
                {
                    Vector3 screenPoint = MUtility.UIWorldToScreenPoint(item.transform.position);

                    if (KGUI_Utility.IsAreaContains(screenPoint, item.panelSize, hand))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }