Esempio n. 1
0
        /// <summary>
        /// 设置项目文件夹、路径等
        /// </summary>
        public void Setup()
        {
            switch (Application.platform)
            {
            case RuntimePlatform.Android:
            case RuntimePlatform.IPhonePlayer:
                appenvironmentalpath = Application.persistentDataPath + "/" + projectname + "/";
                break;

            case RuntimePlatform.WindowsEditor:
            case RuntimePlatform.OSXEditor:
                string tmp   = Application.dataPath;
                int    index = tmp.IndexOf("Asset");
                tmp.Substring(0, index);
                appenvironmentalpath = tmp + "/" + projectname + "/";
                break;

            case RuntimePlatform.OSXPlayer:
            case RuntimePlatform.WindowsPlayer:
                appenvironmentalpath = Application.dataPath + "/" + projectname + "/";
                break;
            }
            //获取不同平台需要获取的相册路径
            photopath       = Createforld(Crossplatformbridge.Getinstance().Getpath() + "/" + projectname);
            recordingpath   = Createforld(System.IO.Path.Combine(appenvironmentalpath, recordingfolder));
            assetmodulspath = Createforld(System.IO.Path.Combine(appenvironmentalpath, assetmodulsfolder));
            databasepath    = Createforld(System.IO.Path.Combine(appenvironmentalpath, databasefolder));
            marklesspath    = Createforld(System.IO.Path.Combine(appenvironmentalpath, marklessfolder));
            thumbnailspath  = Createforld(System.IO.Path.Combine(appenvironmentalpath, thumbnailsfolder));
        }
Esempio n. 2
0
        /// <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("识别图已存储到相册"));
        }
Esempio n. 3
0
        /// <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("录像已存到本地");
        }
Esempio n. 4
0
        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();
            }
        }