public virtual void DeSerialize(XmlElement root) { DeSerializeField(root, "name", ref m_name); DeSerializeField(root, "rotateAngle", ref rotateAngle); DeSerializeField(root, "rotateOffset", ref rotateOffset); DeSerializeField(root, "color", ref color); DeSerializeField(root, "contentColor", ref contentColor); DeSerializeField(root, "backgroundColor", ref backgroundColor); DeSerializeField(root, "active", ref m_active); DeSerializeField(root, "enable", ref m_enable); calculator.DeSerialize(root.SelectSingleNode("RectCalculator") as XmlElement); children.Clear(); XmlElement ele = root.SelectSingleNode("children") as XmlElement; for (int i = 0; i < ele.ChildNodes.Count; i++) { XmlElement child = ele.ChildNodes[i] as XmlElement; Type type = GUINodes.nodeTypes.Find((tmp) => { return(tmp.Name == child.GetAttribute("ElementType")); }); GUINode element = Activator.CreateInstance(type, null) as GUINode; element.DeSerialize(child); element.parent = this; } }
public static void LoadXmlPrefab(this GUINode e, string path) { XmlDocument doc = new XmlDocument(); doc.Load(path); if (doc.DocumentElement.Name != "Element_Prefab") { return; } string attr = doc.DocumentElement.GetAttribute("Type"); Type type = GUINodes.nodeTypes.Find((t) => { return(t.Name == attr); }); GUINode element = Activator.CreateInstance(type) as GUINode; element.DeSerialize(doc.FirstChild.FirstChild as XmlElement); e.Node(element); }