/// <summary> /// 打开url路径下的XML文件 /// </summary> /// <param name="url">文件路径</param> /// <param name="model">将从XML读取的内容存放在该Model中</param> /// <returns></returns> public static bool Open(string url, TreeModel model) { XmlTextReader reader = new XmlTextReader(url); //打开该文件,自带检测该文件是否存在 model.Initialize(); //初始化 while (reader.Read()) { if (reader.NodeType == XmlNodeType.Element) { switch (reader.Name) { case "Model": ParseModelElement(reader, model); break; case "Variable": ParseVariableElement(reader, model); break; case "Mesh": ParseMeshElement(reader, model); break; } } } reader.Close(); return(true); }
void InitTreeModels() { TreeModels = new List <TreeModel>(TreeModelCount); for (int i = 0; i < TreeModelCount; i++) { TreeModel treeModel = gameObject.AddComponent <TreeModel>(); treeModel.Initialize(); treeModel.EnvironmentParams = EnvironmentParams; treeModel.TreeLocalPosition = TreeModelPoints[i]; TreeModels.Add(treeModel); } }