Unity 5.5 Save User Created Levels to Folder Please help me :(


i have a problem: I have made a Survival Game with Random Generated Levels. Now i want that the User can create his own World. So i have an Input Field for the Worlds name- and i dont now how to write a script with create this World with a Ui Button (public void). I tryed to create a Scene in runtime and add it to the Buildsettings but this dont work. So i have to Save the Scene in a Folder to the Application.persitend Data path. But how does i create a Scene and save it to the Folder. Is that even possible?
Like in minecraft.- for every World it created a new Folder wiht the World Data path.
I think i should use System.IO- but im new in C# so i have no good idea. Thanks in adnvance!!

Thank you,


here is an example of writing to a hard drive. you can also use File.ReadAllBytes if you want to store in byte arrays. there is no automated way to save a level. you have to gather and save the information your game needs through code and write it your self. you need good understanding of strings and split parce functions and possibly a good understanding of byte arrays. you would need to design your own system through code depending on what your game needs. a common example would be adding info about what may have changed to a string with a seporator character and then when “loading” you would use String.split to transfer the info into an array. then use String.parce to change back into numbers.

// need this at top of script
using System; 
using System.IO; 
using System.Diagnostics;

     //write a file to a hard drive like this:
     File.WriteAllText(C:/somefolder/somefile.txt,"blah blah blah");
     //read a file on a hard drive like this:
     String txt;
        print("got this: "+txt);}

Thats awesome!!! Thanks :slight_smile:
I already tryed it out- it works very good!
Is it always possible to save floats with that- if i would convert a foat with ToString();
to a string, save it- how can i convert the string to a float on loading, because my player health need a float for the var ??

Thank you very much :slight_smile: