// https://forum.unity3d.com/threads/xml-reading-a-xml-file-in-unity-how-to-do-it.44441/ private IEnumerator LoadGML(string url) { gml = new GML(); xml = new XmlDocument(); xml.Load(url); yield return(xml); XmlNode root = xml.FirstChild; XmlNode tag = root["tag"]; XmlNode header = tag["header"]; XmlNode environment = header["environment"]; XmlNode up = environment["up"]; XmlNode screenBounds = environment["screenBounds"]; gml.screenBounds.x = float.Parse(screenBounds["x"].InnerText) * globalScale.x; gml.screenBounds.y = float.Parse(screenBounds["y"].InnerText) * globalScale.y; gml.screenBounds.z = float.Parse(screenBounds["z"].InnerText) * globalScale.z; Debug.Log("dim: " + gml.screenBounds); XmlNode drawing = tag["drawing"]; for (int i = 0; i < drawing.ChildNodes.Count; i++) { GMLStroke stroke = new GMLStroke(); XmlNode strokeEl = drawing.ChildNodes[i]; for (int j = 0; j < strokeEl.ChildNodes.Count; j++) { XmlNode pt = strokeEl.ChildNodes[j]; float x = float.Parse(pt["x"].InnerText) * gml.screenBounds.x; float y = float.Parse(pt["y"].InnerText) * gml.screenBounds.y; float z = float.Parse(pt["z"].InnerText) * gml.screenBounds.z; float time = float.Parse(pt["time"].InnerText); GMLPoint point = new GMLPoint(); point.pt = new Vector3(x, y, z); point.time = time; stroke.points.Add(point); } gml.strokes.Add(stroke); } if (gmlMode == GMLMode.READ_STILL) { for (int i = 0; i < gml.strokes.Count; i++) { latkd.makeCurve(gml.strokes[i].getPoints()); } } else if (gmlMode == GMLMode.READ_DRAW) { ready = true; } }
private void Start() { ld.makeCurve(points); }