void Start() { //获取路标点数据 _WaypointsXML.GetXmlData(WaypointsModelAll, null, waypointsData.text); Debug.Log("赛道总长度:" + CalcTotalDis().ToString());//计算赛道长度 }
/// 加载XML至路标点 <summary> /// 加载XML至路标点 /// </summary> /// <param name="xmlFileName">xml文件名(不包含路径)</param> /// <param name="all">路标点集合(父物体)</param> public void LoadXmlToWaypoints(WaypointMessage all, string xmlPath = null, string xmlString = null) { WaypointsXML temWaypointsXML = new WaypointsXML(); WaypointsModel temWM = new WaypointsModel(); int number = 0; all.WaypointsModelAll.Clear(); //销毁子物体 DestroyChild(all.transform); //获取XML数据至集合 temWaypointsXML.GetXmlData(all.WaypointsModelAll, xmlPath, xmlString); for (int i = 0; i < all.WaypointsModelAll.Count; i++) { number++; //在编辑器中则创建 if (Application.platform == RuntimePlatform.WindowsEditor) { GameObject go = new GameObject(); go.transform.parent = all.transform; go.name = all.WaypointsModelAll[i].Index.ToString(); go.transform.position = all.WaypointsModelAll[i].Position; go.transform.rotation = all.WaypointsModelAll[i].Rotation; go.transform.localScale = all.WaypointsModelAll[i].Scale; } } if (Debug.isDebugBuild) { Debug.Log("【" + all.WaypointsModelAll.Count.ToString() + "】加载完成:" + all.curWaypointsXMLPath); } }
void Start() { //获取路标点数据 _WaypointsXML.GetXmlData(WaypointsModelAll, null, waypointsData.text); }