コード例 #1
0
    // Update is called once per frame
    //private void Update () {

    //}


    //Get the storage information
    //ストレージの情報を取得する
    public void GetInfo()
    {
        XDebug.Clear();
        //XDebug.Log("Application.dataPath = " + Application.dataPath);                         //ゲームデータのフォルダーパスを返します(読み取り専用)
        XDebug.Log("Application.persistentDataPath = " + Application.persistentDataPath);       //永続的なデータディレクトリのパスを返します(読み取り専用)
        //XDebug.Log("Application.streamingAssetsPath = " + Application.streamingAssetsPath);   //StreamingAssets フォルダーへのパスが含まれています(読み取り専用)
        //XDebug.Log("Application.temporaryCachePath = " + Application.temporaryCachePath);     //一時的なデータ、キャッシュのディレクトリパスを返します(読み取り専用)値はデータを保存できる一時的なディレクトリパスです。

#if !UNITY_EDITOR && UNITY_ANDROID
        XDebug.Log("----------------------------");
        XDebug.Log("IsExternalStorageEmulated = " + AndroidPlugin.IsExternalStorageEmulated());
        XDebug.Log("IsExternalStorageRemovable = " + AndroidPlugin.IsExternalStorageRemovable());
        XDebug.Log("IsExternalStorageMounted = " + AndroidPlugin.IsExternalStorageMounted());
        XDebug.Log("IsExternalStorageMountedReadOnly = " + AndroidPlugin.IsExternalStorageMountedReadOnly());
        XDebug.Log("IsExternalStorageMountedReadWrite = " + AndroidPlugin.IsExternalStorageMountedReadWrite());
        XDebug.Log("GetExternalStorageState = " + AndroidPlugin.GetExternalStorageState());
        XDebug.Log("GetExternalStorageDirectory = " + AndroidPlugin.GetExternalStorageDirectory());
        XDebug.Log("GetExternalStorageDirectoryAlarms = " + AndroidPlugin.GetExternalStorageDirectoryAlarms());
        XDebug.Log("GetExternalStorageDirectoryDCIM = " + AndroidPlugin.GetExternalStorageDirectoryDCIM());
        XDebug.Log("GetExternalStorageDirectoryDocuments = " + AndroidPlugin.GetExternalStorageDirectoryDocuments());
        XDebug.Log("GetExternalStorageDirectoryDownloads = " + AndroidPlugin.GetExternalStorageDirectoryDownloads());
        XDebug.Log("GetExternalStorageDirectoryMovies = " + AndroidPlugin.GetExternalStorageDirectoryMovies());
        XDebug.Log("GetExternalStorageDirectoryMusic = " + AndroidPlugin.GetExternalStorageDirectoryMusic());
        XDebug.Log("GetExternalStorageDirectoryNotifications = " + AndroidPlugin.GetExternalStorageDirectoryNotifications());
        XDebug.Log("GetExternalStorageDirectoryPictures = " + AndroidPlugin.GetExternalStorageDirectoryPictures());
        XDebug.Log("GetExternalStorageDirectoryPodcasts = " + AndroidPlugin.GetExternalStorageDirectoryPodcasts());
        XDebug.Log("GetExternalStorageDirectoryRingtones = " + AndroidPlugin.GetExternalStorageDirectoryRingtones());
#endif
    }
コード例 #2
0
    bool isSaving     = false;          //Ignore while saving.

    //Run screenshot
    public void ScreenShot()
    {
        if (isSaving)
        {
            return;     //Ignore while saving.
        }
        string fileName = filePrefix + DateTime.Now.ToString("yyMMdd_HHmmss") + ".png";
        string dir      = Application.persistentDataPath;

#if UNITY_EDITOR
        dir = Application.dataPath + "/..";
#elif UNITY_ANDROID
        if (!AndroidPlugin.CheckPermission("android.permission.WRITE_EXTERNAL_STORAGE"))
        {
            XDebug.Log("'WRITE_EXTERNAL_STORAGE' permission denied.");
            return;
        }

        dir = AndroidPlugin.GetExternalStorageDirectoryPictures();
        if (string.IsNullOrEmpty(dir))
        {
            dir = AndroidPlugin.GetExternalStorageDirectory();
        }
#endif

        string path = dir + "/" + fileName;
        StartCoroutine(StartScreenshot(path));
    }
コード例 #3
0
        // Update is called once per frame
        //private void Update()
        //{

        //}


        //Run screenshot with automatic path
        public void StartScreenshot()
        {
            string fileName = filePrefix + DateTime.Now.ToString("yyMMdd_HHmmss") + ".png";
            string dir      = Application.persistentDataPath;

            //I think that you may add processing for each platform here.
#if UNITY_EDITOR
            dir = Application.dataPath + "/..";
#elif UNITY_ANDROID
            if (toExternalStorageOnAndroid)
            {
                if (!AndroidPlugin.CheckPermission("android.permission.WRITE_EXTERNAL_STORAGE"))
                {
                    if (OnError != null)
                    {
                        OnError.Invoke("'WRITE_EXTERNAL_STORAGE' permission denied.");
                    }
                    return;
                }

                dir = AndroidPlugin.GetExternalStorageDirectoryPictures();
                if (string.IsNullOrEmpty(dir))
                {
                    dir = AndroidPlugin.GetExternalStorageDirectory();
                }
            }
#endif
            string path = dir + "/" + fileName;
            StartScreenshot(path);
        }
コード例 #4
0
#pragma warning disable 0219
    //For debug

    //Load the specified path by pressing the button.   //ボタン押下で指定パスを読み込む。
    public void TestLoadImage()
    {
        string path = "";
        string file = "/_Test/Images/CheckerTile.png";

#if UNITY_EDITOR
        path = Application.dataPath + file;
#elif UNITY_ANDROID
        path = AndroidPlugin.GetExternalStorageDirectoryPictures() + file;
#endif
        XDebug.Log("TestLoadImage : path = " + path);
        if (!string.IsNullOrEmpty(path))
        {
            LoadAndSetImage(path, 256, 256);
        }
    }
コード例 #5
0
    bool isSaving     = false;          //Ignore while saving.

    //Run screenshot
    public void ScreenShot()
    {
        if (isSaving)
        {
            return;     //Ignore while saving.
        }
        string fileName = filePrefix + DateTime.Now.ToString("yyMMdd_HHmmss") + ".png";
        string dir      = Application.persistentDataPath;

#if UNITY_EDITOR
        dir = Application.dataPath + "/..";
#elif UNITY_ANDROID
        dir = AndroidPlugin.GetExternalStorageDirectoryPictures();
        if (string.IsNullOrEmpty(dir))
        {
            dir = AndroidPlugin.GetExternalStorageDirectory();
        }
#endif
        string path = dir + "/" + fileName;
        StartCoroutine(StartScreenshot(path));
    }