Example #1
0
        public override void Update()
        {
            if (!Wnd.IsShow)
            {
                return;
            }

            if (TargetObject == null)
            {
                Wnd.ResetGuideStep();
                Wnd.Close();
                return;
            }

            CheckTargetObjPosChange();
            UpdateGuideObjPos();
            CheckTargetObjVisibility();
        }
Example #2
0
        private void CheckTargetObjVisibility()
        {
            var visible = true;

            if (TargetCanbeHit)
            {
                var current_camera = UIMainCtrl.MainCam;
                if (current_camera == null)
                {
                    visible = false;
                }

                var screen_pos = current_camera.WorldToScreenPoint(Bounds.center);

                if (pointerData == null)
                {
                    pointerData = new PointerEventData(EventSystem.current);
                }

                var hit_obj = UGUIMath.GetRaycastObj(screen_pos, pointerData);
                if (hit_obj == Wnd.EventMask)
                {
                    visible = false;
                }
                else if (hit_obj == null)
                {
                    visible = false;
                }
                else
                {
                    if (CopyObj != null)
                    {
                        if (!UGUIMath.ContainWidget(CopyObj, hit_obj))
                        {
                            visible = false;
                        }
                    }
                    else if (TargetObject != null)
                    {
                        if (!UGUIMath.ContainWidget(TargetObject, hit_obj))
                        {
                            visible = false;
                        }
                    }
                }
            }
            else
            {
                visible = TargetObject.activeInHierarchy;
            }

            if (!visible)// 因为UGUI的Layout有可能并不是在当前帧完成排版,因此对于强制指引,不可见时需要等待一会儿再重置
            {
                if (m_StartInvisible == false)
                {
                    m_InvisibleTime  = Time.time;
                    m_StartInvisible = true;
                }

                if (CopyObj == null || Time.time - m_InvisibleTime > m_CloseDelayTime)
                {
                    Wnd.ResetGuideStep();
                    Wnd.Close();
                }
            }
        }