示例#1
0
        public static BuildableComponent Deserialize(XmlReader xmlReader)
        {
            if (componentTypes == null)
            {
                componentTypes = FindComponentsInAssembly();
            }

            string componentTypeName = xmlReader.GetAttribute("type");

            if (componentTypes.ContainsKey(componentTypeName))
            {
                xmlReader = xmlReader.ReadSubtree();
                Type               t          = componentTypes[componentTypeName];
                XmlSerializer      serializer = new XmlSerializer(t);
                BuildableComponent component  = (BuildableComponent)serializer.Deserialize(xmlReader);
                //// need to set name explicitly (not part of deserialization as it's passed in)
                component.Type = componentTypeName;
                return(component);
            }
            else
            {
                UnityDebugger.Debugger.LogErrorFormat(ComponentLogChannel, "There is no deserializer for component '{0}'", componentTypeName);
                return(null);
            }
        }
示例#2
0
        public static BuildableComponent Deserialize(JToken jtoken)
        {
            if (componentTypes == null)
            {
                componentTypes = FindComponentsInAssembly();
            }

            string componentTypeName = jtoken["Component"]["Type"].ToString();

            if (componentTypes.ContainsKey(componentTypeName))
            {
                Type t = componentTypes[componentTypeName];
                BuildableComponent component = (BuildableComponent)jtoken["Component"].ToObject(t);
                //// need to set name explicitly (not part of deserialization as it's passed in)
                component.Type = componentTypeName;
                return(component);
            }
            else
            {
                UnityDebugger.Debugger.LogErrorFormat(ComponentLogChannel, "There is no deserializer for component '{0}'", componentTypeName);
                return(null);
            }
        }
示例#3
0
 public BuildableComponent(BuildableComponent other)
 {
     Type = other.Type;
 }