void Update() { if (Input.GetKeyDown(KeyCode.S)) { TakeScreenshot(); } if (Input.GetKeyDown(KeyCode.F)) { ScreenshotHelper.iCaptureScreen((texture2D) => { // Clear the old texture if exist. if (m_CubeMeshRenderer.material.mainTexture != null) { Texture.Destroy(m_CubeMeshRenderer.material.mainTexture); } // Set the new (captured) screenshot texture to the cube renderer. m_CubeMeshRenderer.material.mainTexture = texture2D; string savePath = new FilePathName().SaveTextureAs(texture2D); Debug.Log("Result - Texture resolution: " + texture2D.width + " x " + texture2D.height + "\nSaved at: " + savePath); }); } }
/// <summary> /// can throw exception in case of error /// </summary> private void PerformSave(string fileName) { using (var file = File.Create(fileName)) { Config.SaveXml(file); } // succeeded FilePathName.SetValue(fileName); FilePathValid.SetValue(true); HasChanges.SetValue(false); }
private void DoNew() { if (!CanDiscardOldData("Create New Configuration")) { return; } Config.Reset(); FilePathName.SetValue(FileNameNew); FilePathValid.SetValue(false); HasChanges.SetValue(false); }
public void TakeScreenshot() { ScreenshotHelper.iCaptureWithCamera(m_Camera, (texture2D) => { // Clear the old texture if exist. if (m_CubeMeshRenderer.material.mainTexture != null) { Texture.Destroy(m_CubeMeshRenderer.material.mainTexture); } // Set the new (captured) screenshot texture to the cube renderer. m_CubeMeshRenderer.material.mainTexture = texture2D; string savePath = new FilePathName().SaveTextureAs(texture2D); Debug.Log("Result - Texture resolution: " + texture2D.width + " x " + texture2D.height + "\nSaved at: " + savePath); }); }
/// <summary> /// can throw exception in case of error /// </summary> private void PerformOpen(string fileName) { try { using (var file = File.OpenRead(fileName)) { Config.ReadXml(file); } } catch (Exception) { Config.Reset(); throw; } // succeeded FilePathName.SetValue(fileName); FilePathValid.SetValue(true); HasChanges.SetValue(false); }
public void ParseExtractLine(string line) { IsMisfit = false; PdfAble = false; HasRev = false; HasSht = false; HasExt = false; Server = Program.serverName; if (line.EndsWith(".ss")) { IsMisfit = true; } if (Program.isWindows) { //do parsing logic for windows List <string> windowsData = line.Split(' ').ToList(); windowsData.RemoveAll(String.IsNullOrEmpty); FileSize = Convert.ToInt64(windowsData[0]); if (Program.isLuDateTime) { FileDateTime = DateTime.ParseExact(windowsData[1] + ' ' + windowsData[2], "dd.MM.yyyy HH:mm:ss", CultureInfo.CreateSpecificCulture("en-US")); FilePathName = windowsData[3]; } else if (Program.isIeDateTime) { FileDateTime = DateTime.ParseExact(windowsData[1] + ' ' + windowsData[2], "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture); FilePathName = windowsData[3]; } else { FileDateTime = Convert.ToDateTime(windowsData[1] + ' ' + windowsData[2] + ' ' + windowsData[3]); FilePathName = windowsData[4]; } int idx = FilePathName.LastIndexOf('\\'); FilePath = FilePathName.Substring(2, idx + 1); FileName = FilePathName.Substring(idx + 1); PdfAbleFileName = FileName; if (FileName.EndsWith("._")) { PdfAbleFileName = FileName.Remove(FileName.Length - 2, 2); } PdfAble = Extensions.IsPdfAble(PdfAbleFileName); string[] dataFileSplit = FilePathName.Split('.'); int idx2 = dataFileSplit[0].LastIndexOf('\\'); ItemName = dataFileSplit[0].Substring(idx2 + 1); if (dataFileSplit.Length == 2) { HasExt = true; ItemExt = dataFileSplit[1]; UncRaw = UncPath.BuildUncRawPath(Program.uncRawPrefix, FilePathName); UncPdf = UncPath.BuildUncPdfPath(Program.uncPdfPrefix, ItemName, ItemRev); } else if (dataFileSplit.Length > 2) { if (!Extensions.IsExt(dataFileSplit[1])) { HasRev = true; ItemRev = dataFileSplit[1]; } else { HasExt = true; ItemExt = dataFileSplit[1]; } if (!Extensions.IsExt(dataFileSplit[2])) { HasSht = true; ItemSht = dataFileSplit[2]; ItemShtNum = ExtractNumSht(ItemSht); } else { HasExt = true; ItemExt = dataFileSplit[2]; } if (dataFileSplit.Length > 3 && Extensions.IsExt(dataFileSplit[3])) { HasExt = true; ItemExt = dataFileSplit[3]; } if (!HasRev && !HasSht && !HasExt) { IsMisfit = true; } UncRaw = UncPath.BuildUncRawPath(Program.uncRawPrefix, FilePathName); UncPdf = UncPath.BuildUncPdfPath(Program.uncPdfPrefix, ItemName, ItemRev); } else { IsMisfit = true; } } else { //parsing logic for linux //populate all data in PDMItem by parsing line with Linux rules List <string> linuxData = line.Split(' ').ToList(); linuxData.RemoveAll(String.IsNullOrEmpty); linuxData.RemoveRange(0, 4); //if there was whitespace in filename, join back together, remove last item in array if (linuxData.Count == 6) { linuxData[4] = String.Join(" ", linuxData[4], linuxData[5]); linuxData.Remove(linuxData[5]); } FileSize = Convert.ToInt64(linuxData[0]); FileMonth = linuxData[1]; FileDay = linuxData[2]; if (linuxData[3].Contains(":")) { FileYear = "2017"; FileTime = linuxData[3]; } else { FileYear = linuxData[3]; FileTime = "00:00"; } FileDateTime = Convert.ToDateTime(FileMonth + ' ' + FileDay + ' ' + FileYear + ' ' + FileTime); FilePathName = linuxData[4]; int idx = FilePathName.LastIndexOf('/'); FilePath = FilePathName.Substring(0, idx + 1); FileName = FilePathName.Substring(idx + 1); PdfAbleFileName = FileName; if (FileName.EndsWith(".Z")) { PdfAbleFileName = FileName.Remove(FileName.Length - 2, 2); } PdfAble = Extensions.IsPdfAble(PdfAbleFileName); string[] linuxDataFileSplit = FilePathName.Split('.'); int idx2 = linuxDataFileSplit[0].LastIndexOf('/'); ItemName = linuxDataFileSplit[0].Substring(idx2 + 1); if (linuxDataFileSplit.Length == 2) { HasExt = true; ItemExt = linuxDataFileSplit[1]; UncRaw = UncPath.BuildUncRawPath(Program.uncRawPrefix, FilePathName); UncPdf = UncPath.BuildUncPdfPath(Program.uncPdfPrefix, ItemName, ItemRev); } else if (linuxDataFileSplit.Length > 2) { if (!Extensions.IsExt(linuxDataFileSplit[1])) { HasRev = true; ItemRev = linuxDataFileSplit[1]; } else { HasExt = true; ItemExt = linuxDataFileSplit[1]; } if (!Extensions.IsExt(linuxDataFileSplit[2])) { HasSht = true; ItemSht = linuxDataFileSplit[2]; ItemShtNum = ExtractNumSht(ItemSht); } else { HasExt = true; ItemExt = linuxDataFileSplit[2]; } if (linuxDataFileSplit.Length > 3 && Extensions.IsExt(linuxDataFileSplit[3])) { HasExt = true; ItemExt = linuxDataFileSplit[3]; } if (!HasRev && !HasSht && !HasExt) { IsMisfit = true; } UncRaw = UncPath.BuildUncRawPath(Program.uncRawPrefix, FilePathName); UncPdf = UncPath.BuildUncPdfPath(Program.uncPdfPrefix, ItemName, ItemRev); } else { IsMisfit = true; } } }
IEnumerator saveT(CamVideo cv, int w, int h) { Queue <byte[]> frameQueue = cv.frameQueue; int savingFrameNumber = cv.savingFrameNumber; while (frameQueue.Count > 0) { // Generate file path string path = persis + "/frame" + savingFrameNumber + ".raw"; File.WriteAllBytes(path, frameQueue.Dequeue()); savingFrameNumber++; } Destroy(cv); List <Frame> frames = new List <Frame>(); Texture2D temp = new Texture2D(w, h, TextureFormat.RGB24, false); temp.hideFlags = HideFlags.HideAndDontSave; temp.wrapMode = TextureWrapMode.Clamp; temp.filterMode = FilterMode.Bilinear; temp.anisoLevel = 0; for (int i = 0; i < savingFrameNumber; i++) { string BMPpath = persis + "/RECORDING_LPM" + "/frame" + i + ".raw"; if (File.Exists(BMPpath)) { temp.LoadRawTextureData(File.ReadAllBytes(BMPpath)); Color32[] colors = temp.GetPixels32(); yield return(null); Frame frame = new Frame() { Width = w, Height = h, Data = colors }; frames.Add(frame); } else { break; } } Flush(temp); yield return(null); l.updateThis(() => { Directory.Delete(persis + "/RECORDING_LPM", true); SeeEverything(); check.interactable = true; view.transform.GetChild(0).gameObject.SetActive(true); Application.targetFrameRate = 24; }); ProGifEncoder encoder = new ProGifEncoder(0, 5); encoder.SetDelay(70); StartCoroutine(SaveVidFile()); ThreadPriority WorkerPriority = ThreadPriority.BelowNormal; // GetSavePath(string saveDir, string album, string filenameFormatted) string name_ = new FilePathName().GetGifFileName(); ProGifWorker worker = new ProGifWorker(WorkerPriority) { m_Encoder = encoder, m_Frames = frames, persisT = persis, m_FilePath = Application.persistentDataPath + "/" + name_ + ".gif", m_OnFileSaved = Saved, m_OnFileSaveProgress = l.setProgress, }; worker.Start(); // _thread.Start(); }