private void ClickAddPhotos() { Debug.Log("init WcCamera"); PopupCapture.SetActive(true); SetStateButton(false); EventDelegate.Add(buttonCapture.GetComponent <UIButton>().onClick, () => { Texture2D texture2D = new Texture2D(webCamTexture.width, webCamTexture.height); texture2D.SetPixels(webCamTexture.GetPixels()); texture2D.Apply(); webCamTexture.Stop(); File.WriteAllBytes(Application.persistentDataPath + "/" + photosDao.GetAllPicture().Rows.Count.ToString() + ".jpg", texture2D.EncodeToJPG()); pPhotos.StationId = stationId; pPhotos.PhotoFile = photosDao.GetAllPicture().Rows.Count.ToString() + ".jpg"; bool temp = photosDao.InsertPhoto(pPhotos); Debug.Log("capture " + temp); SetStateButton(true); PopupCapture.SetActive(false); webCamTexture.Stop(); } ); EventDelegate.Add(buttonCancel.GetComponent <UIButton>().onClick, () => { SetStateButton(true); webCamTexture.Stop(); PopupCapture.SetActive(false); }); initCamera(1); }
/* * /// note * /// 0 - new station * /// 1 - Home * /// 2 - Find detail * /// 3 - Top station * /// 4 - Add new * /// 5 - Find resuilt * /// 6 - Photo detail */ void Start() { pPhotosDao = new Photos_DAO(); regeventform = new bool[6]; for (int i = 0; i < regeventform.Length; i++) { regeventform[i] = false; } if (!regeventform[1]) { //reg event form home EventDelegate.Add(form[1].GetComponent <Home_UI>().btnAddNew.GetComponent <UIButton>().onClick, Home_Click_AddNew); EventDelegate.Add(form[1].GetComponent <Home_UI>().btnFind.GetComponent <UIButton>().onClick, Home_Click_Find); EventDelegate.Add(form[1].GetComponent <Home_UI>().btnTopStationByFaclilities.GetComponent <UIButton>().onClick, Home_Click_TopStationByFacilities); } resuilt = pPhotosDao.GetAllPicture(); WWW www; for (int i = 0; i < resuilt.Rows.Count; i++) { if (!File.Exists(Application.persistentDataPath + "/" + resuilt[i]["PhotoFile"])) { www = new WWW(Application.streamingAssetsPath + "/Pictures/" + resuilt[i]["PhotoFile"]); // Wait for download to complete - not pretty at all but easy hack for now // and it would not take long since the data is on the local device. while (!www.isDone) { ; } if (String.IsNullOrEmpty(www.error)) { System.IO.File.WriteAllBytes(Application.persistentDataPath + "/" + resuilt[i]["PhotoFile"], www.bytes); } } } }