private static void LoadObject(int id) { if (GetIdNode(id) == null) { return; } GameObject obj = null; for (int i = 0; i < allIdentifiersInScene.Length; i++) { if (allIdentifiersInScene[i].id == id) { obj = allIdentifiersInScene[i].gameObject; } } if (obj == null) { obj = new GameObject(); } XmlNode idNode = GetIdNode(id); //Adds the component with correct values foreach (XmlNode cNode in idNode.ChildNodes) { string cName = cNode.Attributes[0].Value; System.Type cType = System.Type.GetType(cName); Component currentComponent = (obj.GetComponent(cType)) ? obj.GetComponent(cType) : obj.AddComponent(cType); foreach (XmlNode vNode in cNode.ChildNodes) { ScriptReflector.SetComponentVarTo( currentComponent, vNode.Name, ConvertString.ThisType(vNode.InnerText, System.Type.GetType(vNode.Attributes[0].Value))); } } }