Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Recently, I've been working on the core of my engine, and as I'm moving forward I find myself developing throwaway code to read files and simple data into the engine. This got me thinking about how I should implement a file management system.

After a bit of googleing I came across the Unreal Package format, and boy does it look like the perfect one.

I think it's good because the way how it allows you to separate different assets into different packages and allow something like a level to reference the different packages.

I was just wondering, is this possible with C#? Because the built-in serialization API in .NET does not seem to support any form of this, only reading and writing to a single file.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Yes it's possible. You don't have to use the built in serialization API. Create your own serialization methods for the objects you want to read/write to disk.

You can make heavy use of the BitConverter method GetBytes, for writing your data. As well as the various ToType() methods for reading your binary data.

Writing your own means you're in full control of how the data is written. You can structure it however you want, in whatever directory structure you want.

share|improve this answer
    
Ahhh, yes that's true. That will definitely help. Also I was thinking on how to save the objects. When a new object is created in the editor, the user needs to specify the package that is going to reside in (or create a new one if needed). Then, when the time comes when the object is actually saved, I just parse all the root objects and ask them to save their contents to the specific package. What do you think? –  MrWiggels Oct 18 '12 at 21:12
    
Sounds like a good plan. When my objects have other objects in them, I just have the parent object call the save method on the child objects. Passing along whatever file pointer is needed. Just save down the hierarchy and read the same way. Works great. –  Byte56 Oct 18 '12 at 21:21
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.