Hi
So I am currently working on a level editor for my game and I of course need to be able to save the levels my players make. So I first used BinaryFormatter and that worked very good until I got to the part of sharing it. The web server that the levels will be uploaded to can only accept strings. This did not work very well with my BinaryFormatter setup. So I think I need to find a new way but I don’t know any encryption/serialization methods. I need a method so the player can’t edit the level outside the game (like editing parameters in notepad) basically. But I also need to be able to get it as a string that easily can be uploaded to a server. And then when I fetch it I would still be able to get parameters out of it. The web server I am using returns the saved elements as “keys” these keys return two parameters. The name and the data. I need to get the data on the fetch as I need to set the name, author, info e.t.c in the UI.
Now the class I need to save to a file is the following:
[System.Serializable]
class LevelData
{
public string levelName;
public string levelAuthor;
public string date;
public float time;
public bool exported;
public List<ObjectData> objectData = new List<ObjectData>();
}
And that then contains the object data class which looks like this:
[System.Serializable]
public class ObjectData
{
public int objectID;
public float xPos, yPos, zPos, xRot, yRot, zRot, xScale, yScale, zScale, cannonFireRate, cannonRadius;
public string cubeName;
public ObjectData(int newObjectID, float newXPos, float newYPos, float newZPos, float newXRot, float newYRot, float newZRot, float newXScale, float newYScale, float newZScale, string newCubeName, float newCannonRadius, float newCannonFireRate)
{
objectID = newObjectID;
xPos = newXPos;
yPos = newYPos;
zPos = newZPos;
xRot = newXRot;
yRot = newYRot;
zRot = newZRot;
xScale = newXScale;
yScale = newYScale;
zScale = newZScale;
cubeName = newCubeName;
cannonFireRate = newCannonFireRate;
cannonRadius = newCannonRadius;
}
}
So any help is appreciated! I am not the best at explaining things so if you need more info to be able to help then ask for more info. I’ll try my best!
Thanks in advance!