Saving positions of objects

Hi, I want to make an editor for myself so I can make levels for my game on the run on my phone or tablet. All I need to store is a string for an object type, 2d position, rotation and scale.

As a test I’ve managed to save to user prefs but I have each one as a user pref separately. Ie, obj1Type, obj1PoxX, obj1Posy etc which is really silly and obviously not what I want. I’ve read a bit about xml files but I’m a bit confused on the subject.

-Where would these xml files be stored?

-Is it possible I could save the data and send to my computer whenever I want?

-If I eventually wanted to roll it into an editor for users, could they send the data to me for moderation and then the game could download these files from my server?

-Stupid question, but could someone give me a super layman’s explanation of what serialization is?

-Is there a totally different path I should be following instead of using this method to save?

Thanks so much to anyone who provides some info. :slight_smile:

Still struggling with this greatly, but have made a small amount of progress. I’ve created a class for the individual blocks and currently trying to store the name.

import System.Xml;
import System.Xml.Serialization;

public class Block {

    @XmlAttribute('name')
    public var name : String;

}

And then I’ve built a container like in the wiki - basically the same code except I change ‘Monster’ to ‘Block’

import System.Collections.Generic;
import System.Xml.Serialization;

@XmlRoot('BlockCollection')
public class BlockContainer {

    @XmlArray('Blocks')
    @XmlArrayItem('Block')
    public var Blocks : List.<Block> = new List.<Block>();

    public function Save(path : String) {

	print('saving blocks');

        var serializer : XmlSerializer = new XmlSerializer(BlockContainer);
	var stream : Stream = new FileStream(path, FileMode.Create);
	serializer.Serialize(stream, this);
	stream.Close();

    }

    public static function Load(path : String):BlockContainer {

        var serializer : XmlSerializer = new XmlSerializer(BlockContainer);
	var stream : Stream = new FileStream(path, FileMode.Open);
	var result : BlockContainer = serializer.Deserialize(stream) as BlockContainer;
	stream.Close();
	return result;

    }

    public static function LoadFromText(text : String):BlockContainer {

        var serializer : XmlSerializer = new XmlSerializer(BlockContainer);
	return serializer.Deserialize(new StringReader(text)) as BlockContainer;

    }

}

Both of these classes seem to cause no errors. I’m able to create a new Block object in the code below. However, when I try to add that Block object to the List within BlockContainer, it seems nothing is happening. Likewise, calling the Save function on BlockContainer doesn’t reach the print statement I put in the class and also saves nothing. I’ve manually created the path in Application.persistentDataPath so I know it exists.

function testSaveScene() {

    var path = Application.persistentDataPath + '/testSave.xml';
    
    //var xmlStartData : String = '<BlockCollection><Blocks><Block><name>coreyDrake</name></Block></Blocks></BlockCollection>';
    //var blockCollection : BlockContainer = BlockContainer.LoadFromText(xmlStartData);
    var blockCollection = new BlockContainer();
    print(blockCollection.Blocks);
    var testBlock = new Block();
    testBlock.name = 'corey';
    blockCollection.Blocks.Add(testBlock);
    print(blockCollection.Blocks);
    blockCollection.Save(path);

}