/// <summary> /// 引导对象,但点击任意地方继续(支持没有目标物体,比如显示图片) /// </summary> /// <param name="guide_step"></param> /// <param name="target"></param> public void GuideClickMask(Guide.Step guide_step, GameObject target) { CleanupLastGuide(); m_GuideStep = guide_step; GuideGameObject guide_obj = null; if (target != null) { guide_obj = new GuideGameObject(this, target); m_GuideObject = guide_obj; } else { m_GuideObject = null; } SetupGenericEventListener(null, (click_obj) => { if (m_GuideStep != null && m_GuideStep.TargetTrigger != null) { m_GuideStep.TargetTrigger.NotifyClick(); } else { Close(); } }); if (guide_obj != null) { guide_obj.CopyTargetObj(); } // 显示区域类型的控件不可点击` if (guide_step.DisplayType == Guide.EDisplayType.Region) { if (guide_obj != null) { guide_obj.TargetCanbeHit = false; } else { GameDebug.LogError(string.Format("GuideClickMask: guide_step {0} cannot find guide object", guide_step.StepId)); } } //Debug.Log("GuideClickMask" + guide_step.GuideId + " " + guide_step.StepId); // 一定要加mask SetupMask(true); UpdateArrowTips(); StartUpdateTimer(); TryPlayVoice(); }
/// <summary> /// 清理上一次引导的内容 /// </summary> private void CleanupLastGuide() { OnClickListener = null; ClearTargetObjEvent(); if (m_GuideObject != null) { m_GuideObject.Cleanup(); m_GuideObject = null; } }
public override void Close() { ClearTargetObjEvent(); if (m_GuideObject != null) { m_GuideObject.Cleanup(); m_GuideObject = null; } m_GuideStep = null; ClearArrowTips(); m_Mask.SetActive(false); m_EventMask.SetActive(false); CleanupUpdateTimer(); DestroyPreviewModel(); if (mHideWidgetTransform != null) { HideWidget(mHideWidgetTransform.gameObject, false); } }
/// <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(); }