private void Start() { // make sure to set RemoteIP, RemotePrimPort, RemoteSecPort and Trans_Mode before calling go() // only apply when in fileName mode LoadImg = false; LoadImgInfo = new LoadImgObj(); // only apply in full file mode tex = new Texture2D(2, 2); // don't mess with TextureFormat. Texture2D.LoadImage() will always load jpg as RGB24 (R, G, B each as 8-bit 0-1, pixel order?) }
// handle update cycle when in filename transmission mode: // check if new img ready // download newest file from given path // save locally, update content private void FileNameMode_Update() { // if new image to load, load if (LoadImg) { LoadImgObj tmp = LoadImgInfo; try { /*// try sync'd * Debug.Log(string.Format("Downloading new image on main thread from: {0}", tmp.RemotePath)); * WWW www = new WWW(tmp.RemotePath); * while (!www.isDone) * { * if (www.error != null) * { * Debug.Log(string.Format("Error downloading image: {0}", www.error)); * break; * } * } * * Debug.Log(string.Format("Downloaded successfully. Attempting to save locally... localPath: {0}\n", tmp.LocalPath)); * System.IO.File.WriteAllBytes(tmp.LocalPath, www.bytes); * * // update content, pixel count * //Content = body; * //Pixels = new Vector2Int(header[0], header[1]); */ // use coroutine if (!Downloading) { StartCoroutine(DownloadAndUpdate(tmp.RemotePath, tmp.LocalPath)); } else { Debug.Log("Update: Would've started new download but one already executing..."); } // debug //Debug.Log(string.Format("Completed img download. LocalPath: {0}, RemotePath: {1}", tmp.LocalPath, tmp.RemotePath)); LoadImg = false; } catch (Exception ex) { Debug.Log(string.Format("Update: Exception downloading file... remotePath: {0}, localPath: {1}, exception: {2}", tmp.RemotePath, tmp.LocalPath, ex.ToString())); } } }
void HiddenLinkPlayer() { if (!LinkPlayerObj.activeSelf) { return; } LinkPlayerObj.SetActive(false); HiddenCoinInfo(); backgroudScl.enabled = true; backgroudColor.enabled = true; LoadImgObj.SetActive(true); EventDelegate.Add(backgroudColor.onFinished, delegate { Invoke("StartIntoGame", 0.2f); }); }
// handle transmission body processing in file name mode: // specify remote and local paths to be downloaded on main thread private void FileNameMode_PMRE(byte[] body) { // download file at specified address string remotePath = "http://" + RemoteIP + "/NDVI/" + System.Text.Encoding.UTF8.GetString(body); string localPath = KnownFolders.PicturesLibrary.Path + "/NDVI/" + System.Text.Encoding.UTF8.GetString(body); // debug //Debug.Log(string.Format("Attempting to download: localPath: {0}\n", localPath)); //Debug.Log(string.Format("Attempting to download: remotePath: {0}\n", remotePath)); // download, save and update content LoadImgObj tmp = new LoadImgObj(); tmp.RemotePath = remotePath; tmp.LocalPath = localPath; LoadImgInfo = tmp; LoadImg = true; }
void InitHiddenMode() { if (ModeTPos != null) { return; } isSelectMode = true; if (StartBtObj.activeSelf) { StartBtObj.SetActive(false); AudioManager.Instance.PlaySFX(AudioListCtrl.GetInstance().AudioStartBt); } ModeTPos = ModeObj.GetComponent <TweenPosition>(); ModeTPos.from = ModeObj.transform.localPosition; ModeTPos.to = new Vector3(1440f, 0f, 0f); ModeTPos.ResetToBeginning(); backgroudSprite.spriteName = GlobalData.GetInstance().gameMode != GameMode.SoloMode ? "Link" : "QuWei"; if (GlobalData.GetInstance().gameMode == GameMode.SoloMode) { HiddenCoinInfo(); backgroudScl.enabled = true; backgroudColor.enabled = true; LoadImgObj.SetActive(true); EventDelegate.Add(backgroudColor.onFinished, delegate { Invoke("StartIntoGame", 0.2f); }); } else { LinkPlayerObj.SetActive(true); Invoke("ShowPlayerWait", 0.5f); } ModeTPos.PlayForward(); }