// Use this for initialization public void instantiateStage(GameObject s) { stage = s; StageComponents stageComponents = s.GetComponent <StageComponents>(); leftWall = stageComponents.GetLeftWall(); rightWall = stageComponents.GetRightWall(); redArea = stageComponents.GetRedArea(); blueArea = stageComponents.GetBlueArea(); initiated = true; }
private void _SaveStageDataToDisk() { //StageData sd = new StageData(); StageComponents sc = FindObjectOfType <StageComponents>(); StageData sd = new StageData(); Transform leftWall = sc.GetLeftWall().GetComponent <Transform>(); Transform rightWall = sc.GetRightWall().GetComponent <Transform>(); Transform redArea = sc.GetRedArea().GetComponent <Transform>(); Transform blueArea = sc.GetBlueArea().GetComponent <Transform>(); sd.positionBlueAreaX = blueArea.position.x; sd.positionBlueAreaY = blueArea.position.y; sd.positionBlueAreaZ = blueArea.position.z; sd.positionLeftWallX = leftWall.position.x; sd.positionLeftWallY = leftWall.position.y; sd.positionLeftWallZ = leftWall.position.z; sd.positionRedAreaX = redArea.position.x; sd.positionRedAreaY = redArea.position.y; sd.positionRedAreaZ = redArea.position.z; sd.positionRightWallX = rightWall.position.x; sd.positionRightWallY = rightWall.position.y; sd.positionRightWallZ = rightWall.position.z; sd.scaleLeftWallX = leftWall.localScale.x; sd.scaleLeftWallY = leftWall.localScale.y; sd.scaleLeftWallZ = leftWall.localScale.z; sd.scaleRedAreaX = redArea.localScale.x; sd.scaleRedAreaY = redArea.localScale.y; sd.scaleRedAreaZ = redArea.localScale.z; sd.scaleRightWallX = rightWall.localScale.x; sd.scaleRightWallY = rightWall.localScale.y; sd.scaleRightWallZ = rightWall.localScale.z; sd.scaleBlueAreaX = blueArea.localScale.x; sd.scaleBlueAreaY = blueArea.localScale.y; sd.scaleBlueAreaZ = blueArea.localScale.z; print(Application.persistentDataPath); string path = Application.persistentDataPath + "/" + m_curAreaDescription.m_uuid + ".xml"; var serializer = new XmlSerializer(typeof(StageData)); using (var stream = new FileStream(path, FileMode.Create)) { serializer.Serialize(stream, sd); } }