How can I Serialize my code?

Okay, so I want to instantiate an object that has already undergone certain changes during the course of the game but when I instantiate that object it basically sets all the settings back to default and doesn’t copy it as is. Now I suspect this is because the object needs to be serialized, but now my question is what do I have to do to my code in order for it to adhere to the serialization specifications. (P.S) I know I should make all my variables public but I tried that and the default copying outcome remained the same…

This is the script on the object that I want to instantiate:

using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class Slot : MonoBehaviour
{
	public enum ItemName {Empty, Log, Rock, Berry, Fish, Axe};
	
	public int amountOfItem = 0;						//amount of items in the slot
	public int maxAmountOfItem = 64;					//Maximum amount of items allowed per slot
	public Vector2 index; 								//location of the slot in Inventory Array
	public bool isOccupied = false;						//if there is something in the slot
	public ItemName itemName = 0;						//Name of the item base on enum ItemName
	
	Item item;											//Item in the slot
	Image image;										//Image of item in slot
	Image itemImage;									//Image control of the item in the slot;
	Text textAmount;									//Text control for the amount

	//Increase amount of items
	public void IncreaseItem()
	{
		if(amountOfItem < maxAmountOfItem)
		{
			amountOfItem++;
			textAmount.text = amountOfItem.ToString ();
		}
		else
		{
			//Cant add more
		}
	}

	public void IncreaseItem(int amount)
	{
		if(amountOfItem < maxAmountOfItem)
		{
			amountOfItem += amount;
			textAmount.text = amountOfItem.ToString ();
		}
		else
		{
			//Cant add more
		}
	}

	//Decrease amount of items
	public void DecreaseItem()
	{
		if(amountOfItem >= 0)
		{
			amountOfItem--;
			if(amountOfItem > 0)
			{
				textAmount.text = amountOfItem.ToString ();
			}
			else
			{
				removeItem();
			}
		}
	}
	
	public void DecreaseItem(int amount)
	{
		amountOfItem -= amount;
		textAmount.text = amountOfItem.ToString ();
	}

	//Add axe
	public void addAxe()
	{
		addItem (ItemName.Axe);
	}

	//Add BlueBerry
	public void addBerry()
	{
		addItem (ItemName.Berry);
	}

	//Add Item
	public void addItem(ItemName newItem)
	{
		switch(newItem)
		{
		case ItemName.Berry : 
			item = GameObject.Find ("Berry").GetComponent<Berry>();
			break;
		case ItemName.Axe :
			item = GameObject.Find ("Axe").GetComponent<Axe>();
			break;
		}

		itemName = newItem;
		amountOfItem = 0;
		IncreaseItem();
		isOccupied = true;
		image = item.GetComponent<Image>();
		itemImage.sprite = image.sprite;
		itemImage.enabled = true;
		textAmount.enabled = true;
		textAmount.text = amountOfItem.ToString ();
	}

	//Remove Item
	public void removeItem()
	{
		amountOfItem = 0;
		isOccupied = false;
		itemImage.enabled = false;
		textAmount.enabled = false;
	}

	// Use this for initialization
	void Start ()
	{
		itemImage = this.GetComponentInChildren<Image> ();
		textAmount = this.GetComponentInChildren<Text> ();
		textAmount.enabled = false;
		itemImage.enabled = false;
	}
	
	// Update is called once per frame
	void Update ()
	{
	
	}
}

I recommend using XML as it is builtin feature in .net.
First you need to create descriptor classes:

public class WorldContainerDescriptor{
public List<ThingieDescriptor> thingies=new List<ThingieDescriptor>();
}

public class ThingieDescriptor{
public float px,py,pz;
public float rx,ry,rz,rw;
public float int whatever;
}

Then you need to instantiate WorldContainerDescriptor and populate its list with instances mimicking your objects. After that you can serialize this thingie:

string persistancePath = "pathtofile"+".xml";
StreamWriter streamer = new StreamWriter (persistancePath);
XmlSerializer serializer = new XmlSerializer (typeof(WorldContainerDescriptor), "SaveRoot");
serializer.Serialize(streamer,myContainerClassInstance);
streamer.Flush ();
streamer.Close ();

For additional tricks check XmlSerializer .net manual: XmlSerializer Class (System.Xml.Serialization) | Microsoft Learn