/// <summary> /// 初始化有强制的UI引导 /// </summary> private void InitGuideGroundBtn(int taskId) { GuideTaskInfo info = ConfigReader.GuideTaskXmlInfoDict[taskId]; string name = info.BtnName; GuideEventButton = UIGuideModel.Instance.GetUiGuideButtonGameObject(name); if (GuideEventButton == null) { return; } LocalParent = GuideEventButton.transform.parent.gameObject; GuideEventButton.transform.parent = mRoot.transform; GuideEventButton.SetActive(false); GuideEventButton.SetActive(true); GameObject obj = LoadUiResource.LoadRes(mRoot, "Guide/" + info.PrefabName); obj.transform.Find("Label").GetComponent <UILabel>().text = info.Text; obj.transform.localPosition = info.PosXYZ; ButtonOnPress ck = GuideEventButton.AddComponent <ButtonOnPress>(); ck.AddListener(taskId, OnUiGuideBtnFinishEvent, ButtonOnPress.EventType.ClickType); }
public ReadGuideTaskConfig(string xmlFilePath) { //TextAsset xmlfile = Resources.Load(xmlFilePath) as TextAsset; ResourceItem xmlfileUnit = ResourcesManager.Instance.loadImmediate(xmlFilePath, ResourceType.ASSET); TextAsset xmlfile = xmlfileUnit.Asset as TextAsset; if (!xmlfile) { Debug.LogError(" error infos: 没有找到指定的xml文件:" + xmlFilePath); } xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xmlfile.text); XmlNodeList infoNodeList = xmlDoc.SelectSingleNode("Trigger").ChildNodes; for (int i = 0; i < infoNodeList.Count; i++)//XmlNode xNode in infoNodeList) { if ((infoNodeList[i] as XmlElement).GetAttributeNode("TaskID") == null) { continue; } string typeName = (infoNodeList[i] as XmlElement).GetAttributeNode("TaskID").InnerText; GuideTaskInfo guideInfo = new GuideTaskInfo(); guideInfo.TaskId = Convert.ToInt32(typeName); foreach (XmlElement xEle in infoNodeList[i].ChildNodes) { #region 搜索 switch (xEle.Name) { case "TaskId": guideInfo.TaskId = Convert.ToInt32(xEle.InnerText); break; case "Text": guideInfo.Text = Convert.ToString(xEle.InnerText); break; case "PrefabName": guideInfo.PrefabName = Convert.ToString(xEle.InnerText); break; case "PosXYZ": guideInfo.PosXYZ = GameMethod.ResolveToVector3(xEle.InnerText); break; case "ModelID": guideInfo.ModelID = Convert.ToInt32(xEle.InnerText); break; case "IsFinishModel": guideInfo.IsFinishModel = Convert.ToInt32(xEle.InnerText); break; case "GuideType": guideInfo.GuideType = Convert.ToInt32(xEle.InnerText); break; case "BtnName": guideInfo.BtnName = xEle.InnerText; break; case "triggertype": guideInfo.mBtnTriggerType = (ButtonTriggerType)Convert.ToInt32(xEle.InnerText); break; case "type": guideInfo.mDragType = (ButtonDragType)Convert.ToInt32(xEle.InnerText); break; case "times": guideInfo.mTaskTimes = Convert.ToInt32(xEle.InnerText); break; case "Btncoord": guideInfo.mPos = GameMethod.ResolveToVector3(xEle.InnerText); break; case "GuideEffect": guideInfo.GuideEffect = xEle.InnerText; break; } #endregion } ConfigReader.guideTaskXmlInfoDict.Add(guideInfo.TaskId, guideInfo); } }