Error in TorqueXmlDeserializer
by Vishal Bhanderi · in Torque X 2D · 09/06/2008 (3:19 am) · 3 replies
Hi guys,
I'm trying to create an object which references other objects within the scene, but attempting to run the game I get a TorqueXmlDeserializer error. What is the problem with the code below?
Here is the stack trace:
Thanks
I'm trying to create an object which references other objects within the scene, but attempting to run the game I get a TorqueXmlDeserializer error. What is the problem with the code below?
[TorqueXmlSchemaType]
public class TestCollectionObject : TorqueComponent
{
[TorqueXmlDeserializeInclude]
[XmlElement(ElementName = "SwitchObjects")]
private List<ObjectCollectible> switchTypeContainer;
private class ObjectCollectible
{
//The object to change visibilty status
T2DSceneObject myOwner;
T2DCollisionImage collisionImage;
public T2DCollisionImage CollisionImage
{
get { return collisionImage; }
set { collisionImage = value; }
}
public T2DSceneObject SceneObject
{
get { return myOwner; }
set { myOwner = value; }
}
}
}Here is the stack trace:
Unable to create new instance for element CollisionImage on object GarageGames.Torque.PlatformerFramework.TestCollectionObject+ObjectCollectible
---- Assert Long Message ----
at Assert.Fatal(Boolean condition, String message)
at TorqueXmlDeserializer._Error(String message)
at TorqueXmlDeserializer._Error(String format, Object[] args)
at TorqueXmlDeserializer._SetFieldOrProperty(IFieldOrProperty fieldOrProperty, XmlNode element, Object& o)
at TorqueXmlDeserializer._Recurse(XmlNode element, Object& o, TypeInfo ti)
at TorqueXmlDeserializer._RecurseList(XmlNode element, DeserializedList& list, TypeInfo ti)
at TorqueXmlDeserializer._SetFieldOrProperty(IFieldOrProperty fieldOrProperty, XmlNode element, Object& o)
at TorqueXmlDeserializer._Recurse(XmlNode element, Object& o, TypeInfo ti)
at TorqueXmlDeserializer._RecurseList(XmlNode element, DeserializedList& list, TypeInfo ti)
at TorqueXmlDeserializer._SetFieldOrProperty(IFieldOrProperty fieldOrProperty, XmlNode element, Object& o)
at TorqueXmlDeserializer._Recurse(XmlNode element, Object& o, TypeInfo ti)
at TorqueXmlDeserializer._RecurseList(XmlNode element, DeserializedList& list, TypeInfo ti)
at TorqueXmlDeserializer._SetFieldOrProperty(IFieldOrProperty fieldOrProperty, XmlNode element, Object& o)
at TorqueXmlDeserializer._Recurse(XmlNode element, Object& o, TypeInfo ti)
at TorqueXmlDeserializer.Process(String levelFile, Object target)
at TorqueSceneData.Load(String filename, List'1 extraAssemblies)
at TorqueSceneData.Load(String filename)
at SceneLoader.Load(String sceneFileName)Thanks
About the author
#2
It works fine. Is it some kind of bug? Or have I broke something?
Vishal
09/09/2008 (2:19 pm)
Thanks John for replying. The code above is a strip down of what the full class with the problem still happening. I've managed to narrow it down further. When I change Collision related stuff to:Object collisionImage;
public Object CollisionImage
{
get { return collisionImage; }
set { collisionImage = value; }
}It works fine. Is it some kind of bug? Or have I broke something?
Vishal
#3
then you can export to Torque X with changes to your code.
Well, something like this... Hopefully that makes sense. Just try avoiding the generic object type.
John K.,
09/10/2008 (12:39 am)
Ahhhhh.... Your return type is a generic object. Although that is a completely legal type to use, the Reflection code within Torque X will choke on that, because there is not a strong type to create. Instead of using a generic object type, can you create your own simple class, like this?public class MyObject
{
MyObject(){} //constructor
public object data; //wrapped generic object type
} then you can export to Torque X with changes to your code.
MyObject collisionImage;
public MyObject CollisionImage
{
get { return collisionImage; }
set { collisionImage = value; }
} Well, something like this... Hopefully that makes sense. Just try avoiding the generic object type.
John K.,
Associate John Kanalakis
EnvyGames
John K.