public HoverObj(GameObject plant) { plantHoverPrefab = Instantiate(plant, new Vector3(50, 50, 50), plant.transform.rotation); plantHoverPrefab.GetComponent <Plant>().enabled = false; plantPrefabRenderer = plantHoverPrefab.GetComponentInChildren <MeshRenderer>(); plantSelected = plantHoverPrefab.GetComponent <Plant>().plantObject; }
string SaveData() { List <PlantObject> plants = new List <PlantObject>(); //get all attributes of all plants in list for (int i = 0; i < plantCollection.Count; i++) { string name = plantCollection[i].name; //get plant's' attributes float lighting = getVal(plantCollection[i], "Lighting"); float temp = getVal(plantCollection[i], "Temperature"); float water = getVal(plantCollection[i], "Water"); float fertiliser = getVal(plantCollection[i], "Fertiliser"); List <float> depVals = new List <float>(); depVals.Add(lighting); depVals.Add(temp); depVals.Add(water); depVals.Add(fertiliser); PlantObject plantObject = new PlantObject { Name = name, Attributes = depVals, }; plants.Add(plantObject); } ; SaveObject saveObject = new SaveObject { plantObjects = plants, }; return(JsonConvert.SerializeObject(saveObject, Formatting.Indented)); }