资源简介

实现AR的相机功能 录屏功能 拍照功能 选择物体在屏幕中对其进行操作的功能 UI页面滑动的功能

资源截图

代码片段和文件信息

#pragma warning disable 0168 // variable declared but not used.
#pragma warning disable 0219 // variable assigned but not used.

using UnityEngine;
using System;
using System.IO;
using System.Collections;
using System.Runtime.InteropServices;

public class ScreenshotManager : MonoBehaviour
{

    public static event Action ScreenshotFinishedSaving;
    public static event Action ImageFinishedSaving;

#if UNITY_IPHONE

[DllImport(“__Internal“)]
    private static extern bool saveToGallery( string path );

#endif

    /// 
    /// 截屏并保存图片
    /// 

    /// 项目中的图片名
    /// 项目中保存图片的文件夹名
    /// 是否回调方法
    /// 
    public static IEnumerator Save(string fileName string albumName = “MyScreenshots“ bool callback = false)
    {
        bool photoSaved = false;

        string date = System.DateTime.Now.ToString(“dd-MM-yy“);

        ScreenshotManager.ScreenShotNumber++;

        string screenshotFilename = fileName + “_“ + ScreenshotManager.ScreenShotNumber + “_“ + date + “.png“;

        Debug.Log(“Save screenshot “ + screenshotFilename);

#if UNITY_IPHONE

if(Application.platform == RuntimePlatform.IPhonePlayer) 
{
Debug.Log(“iOS platform detected“);

string iosPath = Application.persistentDataPath + “/“ + screenshotFilename;

Application.CaptureScreenshot(screenshotFilename);

while(!photoSaved) 
{
photoSaved = saveToGallery( iosPath );

yield return new WaitForSeconds(.5f);
}

iPhone.SetNoBackupFlag( iosPath );

} else {

Application.CaptureScreenshot(screenshotFilename);

}

#elif UNITY_ANDROID

        if (Application.platform == RuntimePlatform.Android)
        {
            Debug.Log(“Android platform detected“);

            string androidPath = “/../../../../DCIM/“ + albumName + “/“ + screenshotFilename;
            string path = Application.persistentDataPath + androidPath;
            string pathonly = Path.GetDirectoryName(path);
            Directory.CreateDirectory(pathonly);
            //ScreenCapture.CaptureScreenshot(androidPath);
            Application.CaptureScreenshot(androidPath);
            AndroidJavaClass obj = new AndroidJavaClass(“com.ryanwebb.androidscreenshot.MainActivity“);

            while (!photoSaved)
            {
                photoSaved = obj.CallStatic(“scanMedia“ path);

                yield return new WaitForSeconds(.5f);
            }

        }
        else
        {
            Application.CaptureScreenshot(screenshotFilename);
            //ScreenCapture.CaptureScreenshot(screenshotFilename);

        }
#else

while(!photoSaved) 
{
yield return new WaitForSeconds(.5f);

Debug.Log(“Screenshots only available in iOS/Android mode!“);

photoSaved = true;
}

#endif

        if (callback)
            Sc

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-03-13 13:57  TongChengProject\
     目录           0  2018-02-28 10:39  TongChengProject\.vs\
     目录           0  2018-02-28 10:39  TongChengProject\.vs\TongChengProject\
     目录           0  2018-03-06 16:41  TongChengProject\.vs\TongChengProject\v15\
     文件      136704  2018-03-12 18:15  TongChengProject\.vs\TongChengProject\v15\.suo
     目录           0  2018-03-12 16:07  TongChengProject\.vs\TongChengProject\v15\sqlite3\
     文件     1277952  2018-03-12 16:07  TongChengProject\.vs\TongChengProject\v15\sqlite3\storage.ide
     目录           0  2018-03-12 15:47  TongChengProject\Assets\
     目录           0  2018-03-08 13:37  TongChengProject\Assets\Materials\
     文件        2028  2018-03-08 13:37  TongChengProject\Assets\Materials\chuiuv.mat
     文件         207  2018-03-08 13:20  TongChengProject\Assets\Materials\chuiuv.mat.meta
     文件        2022  2018-02-28 18:43  TongChengProject\Assets\Materials\color 1.mat
     文件         229  2018-02-28 16:55  TongChengProject\Assets\Materials\color 1.mat.meta
     文件        2022  2018-02-28 18:43  TongChengProject\Assets\Materials\color 2.mat
     文件         229  2018-02-28 16:55  TongChengProject\Assets\Materials\color 2.mat.meta
     文件        2021  2018-03-05 16:18  TongChengProject\Assets\Materials\color 3.mat
     文件         229  2018-02-28 16:55  TongChengProject\Assets\Materials\color 3.mat.meta
     文件        2019  2018-02-28 16:55  TongChengProject\Assets\Materials\color.mat
     文件         229  2018-02-28 16:34  TongChengProject\Assets\Materials\color.mat.meta
     文件         213  2018-02-28 16:33  TongChengProject\Assets\Materials.meta
     目录           0  2018-03-12 16:00  TongChengProject\Assets\Models\
     目录           0  2018-03-08 13:37  TongChengProject\Assets\Models\Materials\
     文件        2028  2018-03-08 13:37  TongChengProject\Assets\Models\Materials\gougou.mat
     文件         207  2018-03-08 13:33  TongChengProject\Assets\Models\Materials\gougou.mat.meta
     文件         191  2018-03-08 13:33  TongChengProject\Assets\Models\Materials.meta
     文件      556834  2017-09-21 16:03  TongChengProject\Assets\Models\chuiuv.jpg
     文件        1474  2018-03-08 13:21  TongChengProject\Assets\Models\chuiuv.jpg.meta
     文件       38048  2017-09-21 16:03  TongChengProject\Assets\Models\chuizi.fbx
     文件        2001  2018-03-08 13:31  TongChengProject\Assets\Models\chuizi.fbx.meta
     文件        3061  2018-03-12 16:00  TongChengProject\Assets\Models\dog.controller
     文件         207  2018-03-08 14:19  TongChengProject\Assets\Models\dog.controller.meta
............此处省略8749个文件信息

评论

共有 条评论