How do I load a binary file from another game?
I’m trying to load a map file into Unity and put the data into lists of classes.
The map editor is already in C#.
I don’t know how to load the binary in Unity.
How do I load a binary file from another game?
I’m trying to load a map file into Unity and put the data into lists of classes.
The map editor is already in C#.
I don’t know how to load the binary in Unity.
First, I’m hesitant to help anything trying to get into the assets “from another game,” without knowing anything more about who owns that game’s intellectual property, etc.
Second, many gaming platforms will lock off your file access to just the areas under your game’s control.
Third, the idea of working with C# scripting and working with binary files is a well-documented discipline on other sites; it’s too big a topic to even begin to respond with anything useful or in-depth here. File access, parsing, reading bytes, deserializing from byte streams, books have been written.
The game is Marathon by bungie.
Reading a binary file is trivial, there’s an entire namespace in .net specifically for reading/writing data:
As for your specific data… welp, that depends on what’s in that data.
I’m guessing it’s map data. But to give you an idea about the complexity of that question. Lets pretend its an image. OK… you just basically asked “How do I read an image”?
Well… what’s the image format? Reading a jpg, a gif, and a png are all completely different. Thankfully they’re all standardized and have file headers that tell you about the image file so you can parse it based on the format’s standard. But what if it was a custom image format?
And there in lies the problem… the image format may very well be very specific to the software in question. Especially since it’s a map file. That’s not a common standard. Images are used every day across a multitude of systems so we have multiple standards defined. Game maps??? Not so much.
[edit]
I see you’ve added what game it is. OK… well, reading in that map data would probably entail knowledge of that game. Your tasks are going to be:
decipher what the format of what Aleph-One’s map format is
parse that data into a data structure
translate that data structure to something usable in Unity
populate a Unity scene based on that translated data
…
Basically, this is a very NON-trivial task.
System.IO.File.ReadAllBytes() will read the file.
After that it would be up to you to parse it however you like.
You would obviously need to know the precise shapes of the data (eg, three integers named a,b,c
followed by a string named d
, etc.) to do this.
Nothing of that relates to Unity. It’s just data parsing… go nuts!
The modding sites might have some helpful tools for this if you’re brave enough to run their binaries.
There is the map editor that I got the class data from.
You keep posting links, this sort of implies you’re expecting us to just hand you the code that converts this map data to unity.
Which means either…
A converter exists, in which case, you will have just as much luck googling for it as us. We’re not your google.
We write that converter for you, in which case, no… that’s not what we do here. We help you with your scripting/programming issues, we are not a free for hire programmer that will just do the thing with limited information.
That’s awesome! Get to work… nothing stopping you now. It’s just work to turn the binary data into whatever data shapes you need.
Looks like that repo has already handled all the hard work of serializing / deserializing the map files for you:
My plan was to convert the data into my own classes to build the polygons.
Get the vertices then triangulate it.
I put the map file in assets and get that code to read it somehow?
Just be aware that this code (and the code from Bungie) is licensed under the GPL (General Public License) which is not legally compatible with Unity due to the way the license tries to relicense all code that it is linked against. If you need to know the format you can use it to learn that but you can’t actually use the code itself.
I was about to say the same A lot people don’t quite realise what that even means. If you want to release your own game with closed source or under your own license, you probably should just reverse engineer the necessary code from the file format itself. So the best route would be to either find a documentation of the format or if there is none, look at the GPL code and write a format description (in normal human language). Then you can simply start from scratch just based on the format description.
This of course is quite a bit of work. I haven’t looked at the format yet or what kind of features that format / that editor may support. That essentially determines the complexity.
Here is a tutorial about creating procedural geometry with Unity: