Search Unity

How to save info needed to load levels from custom sprite level editor?

Discussion in 'Scripting' started by Sabo, Jan 27, 2015.

  1. Sabo

    Sabo

    Joined:
    Nov 7, 2009
    Posts:
    151
    I'm currently working on a sprite level editor and am a bit unsure about what information to save in the level files so that the game engine can load the sprites needed for any given level.

    Based on my findings it seems as though the Sprite class does not contain enough information by itself since it doesn't contain the spritesheet filename. At the moment my plan is to save the following in the level file (in regards to sprite data):
    • the file path to each spritesheet used in the level
    • the index to the sprite the tile uses, along with something that points out the spritesheet in question
    To avoid having to save a long spritesheet filename for each tile I was thinking about mapping each filename to an int or short and save that index, along with the sprite index, for each tile.

    Is this a reasonable approach? What better ones exist? Also, have I understood things correctly in that using code to do all the work there is no way for unity to create atlases and pack things?