示例#1
0
        // Update is called once per frame
        void Update()
        {
            OverlapCenter = transform.TransformPoint(Center);

            isCheckSphere = Physics.CheckSphere(OverlapCenter, Radius, ~LayerMask.GetMask(IgnoreLayer), TriggerInteraction);

            if (isCheckSphere || isCheckSphere != isLastCheckSphere)
            {
                List <Collider> NowColliders = Physics.OverlapSphere(OverlapCenter, Radius, ~LayerMask.GetMask(IgnoreLayer), TriggerInteraction).ToList();

                LastColliders.RemoveAll(v => v == null);//去除可能出现的空物体

                EnterColliders = SS_GameObject.List_Except(NowColliders, LastColliders, IF_Func);
                ExitColliders  = SS_GameObject.List_Except(LastColliders, NowColliders, IF_Func);
                StayColliders  = SS_GameObject.List_Intersect(NowColliders, LastColliders, IF_Func);

                if (OnOverlapEnter != null && EnterColliders.Count > 0)
                {
                    OnOverlapEnter(EnterColliders);
                }
                if (OnOverlapExit != null && ExitColliders.Count > 0)
                {
                    OnOverlapExit(ExitColliders);
                }
                if (OnOverlapStay != null && StayColliders.Count > 0)
                {
                    OnOverlapStay(StayColliders);
                }

                LastColliders = NowColliders;
            }
            isLastCheckSphere = isCheckSphere;
        }
        public void OnPointerUp(PointerEventData eventData)//抬起事件
        {
            if (!TouchRayDownLists.ContainsKey(eventData.pointerId))
            {
                return;
            }
            //抬起事件

            //触摸事件通知:停止拖拽,抬起
            SS_Ray.UISendEvent(TouchRayDownLists[eventData.pointerId], eventData, ExecuteEvents.pointerUpHandler);

            //点击事件

            List <RaycastResult> UI_List = SS_Ray.UIRayCast(canvas, eventData.position, InterceptTag, IgnoreLayer);//提取物体列表

            if (UI_List.Count > 0)
            {
                UI_List.RemoveAt(0);                   //顶层为自己,剔除。
            }
            List <RaycastResult> Click_List = SS_GameObject.List_Intersect(TouchRayDownLists[eventData.pointerId], UI_List, (RaycastResult a, RaycastResult b) => { return(object.ReferenceEquals(a.gameObject, b.gameObject)); });

            SS_Ray.UISendEvent(Click_List, eventData, ExecuteEvents.pointerClickHandler);

            if (TouchRayDownLists.ContainsKey(eventData.pointerId))
            {
                TouchRayDownLists.Remove(eventData.pointerId);                                                      //去除物体列表
            }
        }
示例#3
0
        // Update is called once per frame
        void Update()//Fixed
        {
            if (points.Count < 2)
            {
                return;
            }

            List <RaycastHit> NowColliders = new List <RaycastHit>();

            points = (Origin != null) ? LinePoints.ConvertAll <Vector3>(a => Origin.SE_Local_To_World(a)) : LinePoints;

            for (int i = 1; i < points.Count; i++)
            {
                point1_To_point2 = points[i] - points[i - 1];
                isCheckBox       = Physics.Raycast(points[i - 1], point1_To_point2, point1_To_point2.magnitude, ~LayerMask.GetMask(IgnoreLayer), TriggerInteraction);

                if (isCheckBox)
                {
                    NowColliders = NowColliders.Union(Physics.RaycastAll(points[i - 1], point1_To_point2, point1_To_point2.magnitude, ~LayerMask.GetMask(IgnoreLayer), TriggerInteraction).ToList()).ToList();
                }
            }

            if (NowColliders.Count > 0 || LastColliders.Count > 0)
            {
                LastColliders.RemoveAll(v => v.collider == null);//去除可能出现的空物体

                EnterColliders = SS_GameObject.List_Except(NowColliders, LastColliders, IF_Func);
                ExitColliders  = SS_GameObject.List_Except(LastColliders, NowColliders, IF_Func);
                StayColliders  = SS_GameObject.List_Intersect(NowColliders, LastColliders, IF_Func);

                if (OnRayCastEnter != null && EnterColliders.Count > 0)
                {
                    OnRayCastEnter(EnterColliders);
                }
                if (OnRayCastExit != null && ExitColliders.Count > 0)
                {
                    OnRayCastExit(ExitColliders);
                }
                if (OnRayCastStay != null && StayColliders.Count > 0)
                {
                    OnRayCastStay(StayColliders);
                }
            }

            LastColliders = NowColliders;
        }
示例#4
0
        // Update is called once per frame
        void Update()
        {
            OverlapCenter = transform.TransformPoint(Center);

            OverlapSize = new Vector3(
                transform.lossyScale.x * Size.x,
                transform.lossyScale.y * Size.y,
                transform.lossyScale.z * Size.z
                ) * 0.5f;

            isCheckBox = Physics.CheckBox(OverlapCenter, OverlapSize, transform.rotation, ~LayerMask.GetMask(IgnoreLayer));

            if (isCheckBox || isCheckBox != isLastCheckBox)
            {
                List <Collider> NowColliders = Physics.OverlapBox(OverlapCenter, OverlapSize, transform.rotation, ~LayerMask.GetMask(IgnoreLayer), TriggerInteraction).ToList();

                LastColliders.RemoveAll(v => v == null);//去除可能出现的空物体

                EnterColliders = SS_GameObject.List_Except(NowColliders, LastColliders, IF_Func);
                ExitColliders  = SS_GameObject.List_Except(LastColliders, NowColliders, IF_Func);
                StayColliders  = SS_GameObject.List_Intersect(NowColliders, LastColliders, IF_Func);

                if (OnOverlapEnter != null && EnterColliders.Count > 0)
                {
                    OnOverlapEnter(EnterColliders);
                }
                if (OnOverlapExit != null && ExitColliders.Count > 0)
                {
                    OnOverlapExit(ExitColliders);
                }
                if (OnOverlapStay != null && StayColliders.Count > 0)
                {
                    OnOverlapStay(StayColliders);
                }

                LastColliders = NowColliders;
            }
            isLastCheckBox = isCheckBox;
        }