unity 中基于NGUI中实现引导,拦截玩家的点击动作
转自
http://blog.csdn.net/niuzb/article/details/52045192
通常游戏中的引导分为两种,强制引导和非强制引导,强制引导只能点被引导的按钮,点屏幕别的界面会提示玩家跟据引导提示走。刚接触ngui代码,大概了解了一下NGUI的工作原理,基本上实现了策划的要求。
在uicamera.cs中拦截玩家的点击事件:
- static public void Notify (GameObject go, string funcName, object obj)
- {
- if (mNotifying > 10) return;
- // Automatically forward events to the currently open popup list
- if (currentScheme == ControlScheme.Controller && UIPopupList.isOpen &&
- UIPopupList.current.source == go && UIPopupList.isOpen)
- go = UIPopupList.current.gameObject;
- if (go && go.activeInHierarchy)
- {
- ///start by jackniu
- //add for tutorial jackniu
- if (TutorialManage.GetInstance().CheckTutorial(go, funcName)) return;
- ///end by jackniu
- ++mNotifying;
- //if (currentScheme == ControlScheme.Controller)
- // Debug.Log((go != null ? "[" + go.name + "]." : "[global].") + funcName + "(" + obj + ");", go);
- go.SendMessage(funcName, obj, SendMessageOptions.DontRequireReceiver);
- ///start by jackniu
- //add for tutorial jackniu
- if ((funcName == "OnPress" && (bool)obj == true) ||
- funcName == "OnClick") {
- //Debug.Log("########path is " + NGUITools.GetHierarchy(go));
- TutorialManage.GetInstance ().MoveToNextStep (go, funcName);
- }
- ///end by jackniu
- if (mGenericHandler != null && mGenericHandler != go)
- mGenericHandler.SendMessage(funcName, obj, SendMessageOptions.DontRequireReceiver);
- --mNotifying;
- }
- }