Search Unity

Exporting the current state of a generated game to another project/build

Discussion in 'Scripting' started by gamesbyangelina, Jul 17, 2013.

  1. gamesbyangelina

    gamesbyangelina

    Joined:
    Jun 23, 2013
    Posts:
    20
    Hi Unity Forums! I've just begun using Unity properly in both my day job and off time. I have a rather big problem looming on the horizon and I'd love some help. First some background:

    In my day job I'm researching techniques for automating game design, as part of a PhD project. It's called ANGELINA, and you can read more here: www.gamesbyangelina.org. I'm just moving to Unity, which is promising many exciting things but also new challenges. ANGELINA is a system that produces games; that is, when you run it it generates a game by testing prototypes, etc. In the past I used Flash or Java as an output language, so ANGELINA would edit existing code files and throw some images in a folder, and I'd compile them at the end. Simple.

    Unity offers much more for me. I've build Editor windows and cool bits of code that pull down resources from all over the web. But there's a problem. ANGELINA produces a game in Unity... but I can't export it. Because the actual game project, the thing I'd be building, is the entire of ANGELINA. When I run ANGELINA in Unity, it produces a game in the Game window and I can play it... but I need to export that game. The game that's just been generated. Not the rest of ANGELINA.

    There's generated level geometry, images and textures selected from the web and folders inside the project, even generated code. I don't know how to export this generated game. I had a few ideas:

    1. Copy all the files I need into a new folder and painstakingly reassemble the game by hand. This will take ages.
    2. Maybe serialise the game state and write a tool to automatically unpack it into a new project?
    3. Ask the Unity Community.

    The first two are an awful lot of work if they're going to fail. So I thought I'd try 3. first and ask you guys. What's your advice on exporting ANGELINA's games into a new Unity project so I can build them for the web? Even better, for bonus love, could this be a process that ANGELINA automates itself?

    Mike
     
  2. tomnullpointer

    tomnullpointer

    Joined:
    Sep 20, 2010
    Posts:
    142
    Yo Mike!

    Really Angelina should be writing a template for the game, rather than the actual game.
    Id make a set of storage classes to hold all the data that is generated when angelina runs.
    i.e. class for holding textures class for entities, even rules and conditions etc - basically abstract what is happening in the game.
    You can then serialize all this data to a series of xml files
    You can serialize and save any procedural meshes (if you make any)
    Save any textures youve downloaded etc
    A list of entities and positions etc

    Then the 'player' part of your code would read these back in and assemble the game

    You can even write a simple function that reads an xml file and assembles a gameobject based on it.
    your xml would just hold the name of each component and its default values,
    and the script would build the gameobject, attach component and set their values.
    Thats fairly easy to do.

    You will then be essentially be writing 2 engines, the generation one and the playback one
    In the IDE these could overlap, but if you want to export them then you would probably just want the player;

    The web part might be alittle more tricky, simply because using my suggestion all your data will be external and loaded up
    (but thats just a question of permission i spose)


    Hope that helps
     
  3. gamesbyangelina

    gamesbyangelina

    Joined:
    Jun 23, 2013
    Posts:
    20
    Hey Tom! Thanks for posting here.

    It definitely does help. I like the idea of having a second engine that runs games output by the first system. I developed a newer representation today that's a bit less painful to export as well, plus it means I could have a central "ANGELINA Player" which new games are uploaded to which would make distribution easier.

    My one concern is code. ANGELINA generates .cs files with code in that needs to be part of the game. I'm thinking instead of having an ANGELINA Player I might need an ANGELINA Player Project that I can bundle the .cs files in and then export ot a game. What do you think?