public void SerializePlant(PlantPartPanelManager PPPM, string name) { PlantData pd = new PlantData(PPPM.targetedPlant, PPPM.targetedBranch, PPPM.targetedSubBranch, PPPM.targetedLeaf, PPPM.targetedFlower, PPPM.targetedFruit); pd.trunkMatName = PPPM.plantCreatorMaterialManager.trunkMatName; pd.branchMatName = PPPM.plantCreatorMaterialManager.branchMatName; pd.subBranchMatName = PPPM.plantCreatorMaterialManager.subBranchMatName; pd.leafMatName = PPPM.plantCreatorMaterialManager.leafMatName; pd.flowerMatName = PPPM.plantCreatorMaterialManager.flowerMatName; pd.fruitMatName = PPPM.plantCreatorMaterialManager.fruitMatName; string s = JsonUtility.ToJson(pd); //string s = ""; //Test (pd, typeof(PlantData), ref s); string path = Application.persistentDataPath + "/Plants/" + name + ".grenplant"; System.IO.File.WriteAllText(path, s); }
public Plant UnserializePlant(string path, PlantPartPanelManager PPPM) { if (File.Exists(path)) { string file = System.IO.File.ReadAllText(path); test = JsonUtility.FromJson <PlantData> (file); JsonUtility.FromJsonOverwrite(test.trunk, PPPM.targetedPlant); JsonUtility.FromJsonOverwrite(test.branch, PPPM.targetedBranch); JsonUtility.FromJsonOverwrite(test.subBranch, PPPM.targetedSubBranch); JsonUtility.FromJsonOverwrite(test.leaf, PPPM.targetedLeaf); JsonUtility.FromJsonOverwrite(test.flower, PPPM.targetedFlower); JsonUtility.FromJsonOverwrite(test.fruit, PPPM.targetedFruit); PPPM.plantCreatorMaterialManager.LinkMats(); PPPM.plantCreatorMaterialManager.ChangeTexture(test.trunkMatName, PlantPart.Trunk); PPPM.plantCreatorMaterialManager.ChangeTexture(test.branchMatName, PlantPart.Branch, true); PPPM.plantCreatorMaterialManager.ChangeTexture(test.subBranchMatName, PlantPart.SubBranch, true); PPPM.plantCreatorMaterialManager.ChangeTexture(test.leafMatName, PlantPart.Leaf); PPPM.plantCreatorMaterialManager.ChangeTexture(test.flowerMatName, PlantPart.Flower); PPPM.plantCreatorMaterialManager.ChangeTexture(test.fruitMatName, PlantPart.Fruit); PPPM.RemakeLinks(); PPPM.targetedPlant.InitializePlant(); Debug.Log("LOADED PLANT"); } else { throw new FileNotFoundException(); } return(null); }
public void Initialize(PlantPartPanelManager plantPartPanelManager) { this.plantPartPanelManager = plantPartPanelManager; InitializeParameterList(); }