Steve Yeager
  • Games
    • Space CUBEs
    • Knighthood
    • Gemini
    • Robot Pirate Racing
    • Sarah's Adventure
    • Monster Smash
    • Other Projects
  • Learning Resources
  • Resume
  • Bio
  • StarCats

Time to talk about the 0s and the 1s.

1/17/2014

0 Comments

 
    Wanted to make this post after I spent too much time trying to figure out how to read data on Android from a binary file that I had in my Unity project. Long story short (I'm going to transition to bullet points now because I'm a coder, not JRR Tolkien).
  • File needs to have .bytes extension.
  • File needs to be in a folder named Resources.
  • You load the file as a TextAsset with Resources.Load(path).
  • You pass the file.bytes to a Stream to a BinaryReader.
  • Boom. Data.

    I use a binary file to hold all possible CUBEs and their corresponding values. When the game starts I read the file and parse the data into a static array so any class that needs the info can easily acquire it. I am using binary instead of XML because I am targeting mobile and switching from XML to binary saved me about a MB (removed one XML file and the System.XML namespace). 
    However binary is not very easy for me to read and write because I am just a lame human, so I use a local XML file to keep track of CUBE info as I create the game. I then use a tool I created in Unity that finds that file and parses the XML into an array of the info that I need, which I then take and convert to binary and save to the .bytes file for the app to read when the game starts.
0 Comments



Leave a Reply.

    Author

    My name is Steve Yeager and I like to party.

    Archives

    January 2014
    November 2013
    September 2013

    Categories

    All
    Art
    Code
    CUBEs
    Knighthood
    Pathfinding

    RSS Feed

Powered by Create your own unique website with customizable templates.