示例#1
0
        /// <summary>
        /// 点击目标物体的回调
        /// </summary>
        /// <param name="click_obj"></param>
        /// <param name="guide_obj"></param>
        /// <param name="guide_step"></param>
        void OnClickTarget(GameObject click_obj, GuideGameObject guide_obj, Guide.Step guide_step)
        {
            if (m_GuideStep == null || mUIObject == null)
            {
                return;
            }

            if ((guide_obj.CopyObj != null && click_obj == guide_obj.CopyObj) ||
                (guide_obj.CopyObj == null && click_obj == guide_obj.TargetObject))
            {
                if (guide_obj.TargetObject == null)
                {
                    Close();
                    return;
                }

                // 执行guide_obj.TargetObject的点击事件
                if (guide_step.EventType == 1)
                {
                    ExecuteEvents.Execute <IPointerClickHandler>(guide_obj.TargetObject, new PointerEventData(EventSystem.current), ExecuteEvents.pointerClickHandler);
                }
                else
                {
                    ExecuteEvents.Execute <IPointerDownHandler>(guide_obj.TargetObject, new PointerEventData(EventSystem.current), ExecuteEvents.pointerDownHandler);
                    ExecuteEvents.Execute <IPointerUpHandler>(guide_obj.TargetObject, new PointerEventData(EventSystem.current), ExecuteEvents.pointerUpHandler);
                }

                if (click_obj != null)
                {
                    var event_listen = EventTriggerListener.GetListener(click_obj);
                    event_listen.onPointerClick -= OnClick;
                }

                if (m_GuideStep != null && m_GuideStep.TargetTrigger != null)
                {
                    m_GuideStep.TargetTrigger.NotifyClick();
                }
                else
                {
                    Close();
                }
            }
        }
示例#2
0
        /// <summary>
        /// 点击引导对象
        /// </summary>
        /// <param name="guide_step"></param>
        /// <param name="target">要引导的对象</param>
        public void GuideClick(Guide.Step guide_step, GameObject target)
        {
            CleanupLastGuide();

            if (target == null)
            {
                return;
            }

            if (guide_step == null)
            {
                return;
            }

            m_GuideStep = guide_step;

            if (m_GuideObject != null)
            {
                m_GuideObject.Cleanup();
                m_GuideObject = null;
            }

            var guide_obj = new GuideGameObject(this, target);

            m_GuideObject = guide_obj;

            if (!m_GuideStep.IsForcible)
            {
                // 非强制时监听其点击事件
                SetupTargetClickEventListener(guide_obj.TargetObject, m_GuideStep.ClickAny, OnClickTarget);
            }
            else
            {
                guide_obj.CopyTargetObj();
                if (target != null)
                {
                    string hide_widget = m_GuideStep.HideWidget;
                    if (string.IsNullOrEmpty(hide_widget) == false)
                    {
                        if (target.name == hide_widget)
                        {
                            mHideWidgetTransform = target.transform;
                        }
                        else
                        {
                            mHideWidgetTransform = UIHelper.FindChildInHierarchy(target.transform, hide_widget);
                        }
                        if (mHideWidgetTransform != null)
                        {
                            HideWidget(mHideWidgetTransform.gameObject, true);
                        }
                    }
                }

                GameObject listen_object = guide_obj.CopyObj != null ? guide_obj.CopyObj : guide_obj.TargetObject;
                SetupGenericEventListener(listen_object, (click_obj) =>
                {
                    if (m_GuideStep == null || mUIObject == null)
                    {
                        return;
                    }

                    if ((guide_obj.CopyObj != null && click_obj == guide_obj.CopyObj) ||
                        (guide_obj.CopyObj == null && click_obj == guide_obj.TargetObject))
                    {
                        if (guide_obj.TargetObject == null)
                        {
                            Close();
                            return;
                        }

                        // 执行guide_obj.TargetObject的点击事件
                        if (guide_step.EventType == 1)
                        {
                            ExecuteEvents.Execute <IPointerClickHandler>(guide_obj.TargetObject, new PointerEventData(EventSystem.current), ExecuteEvents.pointerClickHandler);
                        }
                        else
                        {
                            ExecuteEvents.Execute <IPointerDownHandler>(guide_obj.TargetObject, new PointerEventData(EventSystem.current), ExecuteEvents.pointerDownHandler);
                            ExecuteEvents.Execute <IPointerUpHandler>(guide_obj.TargetObject, new PointerEventData(EventSystem.current), ExecuteEvents.pointerUpHandler);
                        }

                        if (mHideWidgetTransform != null)
                        {
                            HideWidget(mHideWidgetTransform.gameObject, false);
                        }

                        if (click_obj != null)
                        {
                            var event_listen             = EventTriggerListener.GetListener(click_obj);
                            event_listen.onPointerClick -= OnClick;
                        }

                        if (m_GuideStep != null && m_GuideStep.TargetTrigger != null)
                        {
                            m_GuideStep.TargetTrigger.NotifyClick();
                        }
                        else
                        {
                            Close();
                        }
                    }
                });
            }
            //Debug.Log("GuideClick" + guide_step.GuideId + "   " + guide_step.StepId);

            SetupMask();
            UpdateArrowTips();
            StartUpdateTimer();
            TryPlayVoice();
        }