|
I am currently working on saving and loading objects, and right now I am loading and unloading using JsonFX. This works well except I don't want the data to be in plain text and packed as efficiently as possible. I've read that I should be serializing the data, and this field is completely new to me. I've come across protobuf-net which works well for primitive object serialization, however, there are a few things I haven't been able to get working with it, such as serializing Vector3s, for example. Ideally, at the end of this, I'd like to be able to take a list of game objects, serialize their positions, rotations, and any custom script variables. These game objects will not all have the same scripts attached and I won't need to save all of the variables in each script. With that in mind, can anybody suggest a general idea of how to solve this? My target platform is iOS so I'd like to have as small of a build as possible (as in, no System.xml). I am using c# and have iOS Pro if that matters. Thank you, Justin
(comments are locked)
|
|
Why can't you just convert your Vector3's or Quaternions into float arrays and use those for serialization? That's what I do anyway.. works for me. I thought about that, except I have a lot of different classes which have a unique set of variables. In order for that to work, I would have to write a custom serializable class that corresponds to each class that I want to serialize. So for every Vector3 that I have in one class, I would have to create another Vector3 float array in a corresponding class. In addition, I need to include some properties that are outside the scope of the class (such as game object position/rotation), so I would need some type of abstraction above the first class. For example, if I have the following class: class nonserialClass { int intValue; Vector3 vector3Value; } I would need to convert nonserialClass to the following: class serialClass { int intValue; serializableVector3 vector3Value; serializableVector3 position; serializableQuaternion rotation; } I would need to do this for each class that I have, which seems like it would be a maintenance nightmare... unless there is a different way and I am completely misunderstanding (I hope so!)
Jun 30 '11 at 07:19 PM
opsive
(comments are locked)
|
