public void OnAddImage() { //create new image data ImageData newImageData = new ImageData(20, 20 + (2 * 20), 2020, 20, 20, "newImage"); ALL_IMAGES.Add(newImageData); }
//----------------- Save Data ------------------ #region SAVING AND LOADING public void SaveData() { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Create(Application.persistentDataPath + "/stargazeData.dat"); CustomSaveClass data = new CustomSaveClass(); //format data CustomSaveClass CUSTOM_SAVE_CLASS = new CustomSaveClass(); ImageData[] picTakenArr = ALL_IMAGES.ToArray(); CUSTOM_SAVE_CLASS.picturesTaken = picTakenArr; data = CUSTOM_SAVE_CLASS; //save data bf.Serialize(file, data); file.Close(); }
//--------------- Processing Information ----------------------- void client_MqttMsgPublishReceived(object sender, MqttMsgPublishEventArgs e) { string message = Encoding.Default.GetString(e.Message); Debug.Log(message); Debug.Log(e.Topic); //Debug.Log("Altitude is: " + pos.Altitude); //Debug.Log("Azimuth is: " + pos.Azimuth); if (e.Topic == "IC.embedded/friends/unity/sensors") { ReceivedTelescopePos pos = JsonUtility.FromJson <ReceivedTelescopePos>(message); Debug.Log("Altitude is: " + pos.Altitude); Debug.Log("Azimuth is: " + pos.Azimuth); OnReceivePosUpdate(pos); TelsecopeUpdate = message; } else if (e.Topic == "IC.embedded/friends/unity/camera") { PictureTaken pic = JsonUtility.FromJson <PictureTaken>(message); Debug.Log(pic.Altitude); Debug.Log(pic.Azimuth); Debug.Log(pic.DayTaken); Debug.Log(pic.HourTaken); AASharp.AAS2DCoordinate coor = CoordinateTransformation.ToCelestialCoordinates(pic.Latitude, pic.Longitude, pic.Azimuth, pic.Altitude); OnReceivePic(pic, (float)coor.Y, (float)coor.X); ImageUpdate = message; //create new image data ImageData newImageData = new ImageData((float)coor.Y, (float)coor.X, pic.YearTaken, pic.HourTaken, pic.MinuteTaken, pic.ImageName); ALL_IMAGES.Add(newImageData); SaveData(); } }