コード例 #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;
        }
コード例 #2
0
ファイル: SC_RayCast.cs プロジェクト: yinqianshu/SDHK_Tool
        // 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;
        }
コード例 #3
0
        public void OnStay(PointerEventData eventData)
        {
            List <RaycastResult> UI_List = SS_Ray.UIRayCast(canvas, eventData.position, InterceptTag, IgnoreLayer);//提取物体列表

            if (UI_List.Count < 1)
            {
                return;
            }
            UI_List.RemoveAt(0);//顶层为自己,剔除。

            List <RaycastResult> Enter_List = SS_GameObject.List_Except(UI_List, TouchRayEnterLists[eventData.pointerId], (RaycastResult a, RaycastResult b) => { return(object.ReferenceEquals(a.gameObject, b.gameObject)); });
            List <RaycastResult> Exit_List  = SS_GameObject.List_Except(TouchRayEnterLists[eventData.pointerId], UI_List, (RaycastResult a, RaycastResult b) => { return(object.ReferenceEquals(a.gameObject, b.gameObject)); });

            //触摸事件通知:停留
            SS_Ray.UISendEvent(Enter_List, eventData, ExecuteEvents.pointerEnterHandler);

            //触摸事件通知:离开
            SS_Ray.UISendEvent(Exit_List, eventData, ExecuteEvents.pointerExitHandler);

            TouchRayEnterLists[eventData.pointerId] = new List <RaycastResult>(UI_List);
        }
コード例 #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;
        }