/// <summary> /// 获取识别图图片回调 /// </summary> /// <param name="_bytes"></param> /// <param name="_image"></param> private void GetMarkerless(byte[] _bytes, object _image) { //生成照片名称 string filename = Fileoperation.Generatefilename(".jpg"); string path = Scannermanager.Getinstance().projectconfig.photopath + "/" + filename; //存入本地相册 File.WriteAllBytes(path, _bytes); Crossplatformbridge.Getinstance().Savephoto("/SKbrowser/" + filename); StartCoroutine(Uimanager.Getinstance().Waittoshowtips("识别图已存储到相册")); }
private IEnumerator TakephotoCoroutine() { if (doingbefore != null) { doingbefore.Invoke(); } yield return(new WaitForEndOfFrame()); //获取屏幕上的所有像素写到texture2d内并保存 Texture2D t2d = new Texture2D(screenwidth, screenheight, TextureFormat.ARGB32, false); t2d.ReadPixels(new Rect(0, 0, screenwidth, screenheight), 0, 0, false); t2d.Apply(false); string filename = Fileoperation.Generatefilename(".jpg"); byte[] bytes = t2d.EncodeToJPG(); Fileoperation.Writefiletodisk(Scannermanager.Getinstance().projectconfig.photopath, filename, bytes); Crossplatformbridge.Getinstance().Savephoto(Scannermanager.Getinstance().projectconfig.projectname + "/" + filename); if (doingafter != null) { doingafter.Invoke(); } }
/// <summary> /// 录屏结束后回调 /// </summary> private void Onstoprecording() { isstarted = false; //视屏录制完毕后回调,一般用于隐藏恢复用户提示界面(UI) if (onrecorded != null) { onrecorded(); } curtime = 0; //由于everplayer录屏插件录制的视频将存储到temporarycachpath中 //故我们使用这个路径用C#代码来查找 string tmpfilepath = Application.temporaryCachePath; #if UNITY_IPHONE tmpfilepath = tmpfilepath.Replace("Library/Caches", "tmp"); #endif //使用Directoryinfo 来搜索查询录制下来的视频 DirectoryInfo dir = new DirectoryInfo(tmpfilepath); var files = dir.GetFiles("*.mp4", SearchOption.AllDirectories); var file = files.OrderByDescending(f => f.CreationTime).FirstOrDefault(); if (file != null && string.IsNullOrEmpty(file.FullName)) { return; } string tmpfullname = file.FullName; #if UNITY_ANDROID //搜索到视频后将其另存到我们指定的目录下 Fileoperation.Writefiletodisk(file.FullName, Scannermanager.Getinstance().projectconfig.recordingpath, Fileoperation.Generatefilename(".mp4")); #endif #if UNITY_IPHONE || UNITY_IOS //IOS中存储路径与安卓有差异 string originpath = file.FullName; string temp = originpath.Replace(file.Name, file.Name + "_reencode.mp4"); if (Fileoperation.Fileexist(originpath)) { Crossplatformbridge.Getinstance().Savevideo(originpath, temp); } #endif Uimanager.Getinstance().Showtips("录像已存到本地"); }