private IEnumerator PhotographFile2(SCameraPhotographFileCallBack callback) { if (m_flashType == SCameraFlashType.OPEN) { yield return(new WaitForSeconds(0.5f)); } string baseFile = "/photo_" + System.DateTime.Now.ToString("yyyy_MMdd_hhmm") + ".png"; Debug.LogError("baseFile" + baseFile); string file = Application.persistentDataPath + baseFile; if (File.Exists(file)) { File.Delete(file); } Application.CaptureScreenshot(baseFile, 0); callback(true, file); yield return(new WaitForSeconds(0.5f)); m_cameraDeviceBehaviour.Device.SetFlashTorchMode(false); }
/// <summary> /// 把图片拍摄到文件中 /// </summary> /// <param name="callback">回调函数</param> public override void PhotographFile(SCameraPhotographFileCallBack callback) { PhotographMemory(delegate(bool isOK, Texture2D tex) { try { string baseFile = "/photo_" + System.DateTime.Now.ToString("yyyy_MMdd_hhssmm") + ".png"; string file = Application.persistentDataPath + baseFile; if (File.Exists(file)) { File.Delete(file); } FileStream fs = new FileStream(file, FileMode.Create, FileAccess.Write); byte[] b = tex.EncodeToPNG(); fs.Write(b, 0, b.Length); fs.Close(); callback(true, file); } catch (System.Exception e) { callback(false, e.ToString()); } }); }
/// <summary> /// 把图片拍摄到文件中 /// </summary> /// <param name="callback">回调函数</param> public abstract void PhotographFile(SCameraPhotographFileCallBack callback);