Пример #1
0
    public static IEnumerator Save(string filePath)
    {
        LogView.Add("Save existing file to gallery " + filePath);
#if UNITY_IOS
        string iosPath = Application.persistentDataPath + "/" + filePath;
        saveToGallery(iosPath);
        yield return(new WaitForSeconds(.5f));

        UnityEngine.iOS.Device.SetNoBackupFlag(iosPath);
#elif UNITY_ANDROID
        if (Application.platform == RuntimePlatform.Android)
        {
            AndroidJavaClass obj = new AndroidJavaClass("soulworker.xml.congyu.xmllibrary.UnityCallAndroid");
            int startIdx         = filePath.LastIndexOf("/");
            if (startIdx == -1)
            {
                startIdx = 0;
            }
            else
            {
                startIdx = startIdx + 1;
            }
            int    endIdx   = filePath.LastIndexOf(".");
            string saveName = filePath.Substring(startIdx, endIdx - startIdx);
            LogView.Add("savePicToGallery " + saveName);
            obj.CallStatic("savePicToGallery", saveName);
            yield return(new WaitForSeconds(.5f));
        }
#else
        yield return(new WaitForSeconds(.5f));

        XMLDebug.Log("Screenshots only available in iOS/Android mode!");
#endif
    }
Пример #2
0
 public void SavePictureFinished(bool suc)
 {
     if (suc)
     {
         LogView.Add("Save Success!");
     }
     else
     {
         LogView.Add("Save Failed!");
     }
 }
Пример #3
0
 void SavePicToGalleryMsg(string errorStr)
 {
     if (string.IsNullOrEmpty(errorStr))
     {
         LogView.Add("Save picture to gallery success!");
         SavePicToGallery.CallBackFun(true);
     }
     else
     {
         string msg = string.Format("Save picture to gallery failed! error msg:{0}", errorStr);
         LogView.Add(msg);
         SavePicToGallery.CallBackFun(false);
     }
 }
Пример #4
0
 private void OnGUI()
 {
     if (View.instance.GUIButton("ScreenShot", 200, 60))
     {
         // 注意 android 不能带路径
         ScreenCapture.CaptureScreenshot(FILE_NAME);
         LogView.Add("ScreenShot Success!");
     }
     if (View.instance.GUIButton("SaveToGallery", 200, 60))
     {
         SavePicToGallery.SaveFinished += SavePictureFinished;
         StartCoroutine(SavePicToGallery.Save(Application.persistentDataPath + "/" + FILE_NAME));
         LogView.Add("SaveToGallery Complete!");
     }
     if (View.instance.GUIButton("Check", 200, 60))
     {
         foreach (string s in permissionArray)
         {
             if (Permission.HasUserAuthorizedPermission(s))
             {
                 LogView.Add(string.Format("{0} permission has been granted.", s));
             }
             else
             {
                 LogView.Add(string.Format("{0} permission has not been granted.", s));
             }
         }
     }
     if (View.instance.GUIButton("Request", 200, 60))
     {
         foreach (string s in permissionArray)
         {
             if (Permission.HasUserAuthorizedPermission(s))
             {
                 LogView.Add(string.Format("{0} permission has been granted.", s));
             }
             else
             {
                 LogView.Add(string.Format("Request {0} permission ...", s));
                 Permission.RequestUserPermission(s);
             }
         }
     }
 }
Пример #5
0
 public static void Write(string s, string color = LogUtil.TEAL)
 {
     _logView.Add(string.Format(color, s));
     Debug.Log(string.Format(color, s));
 }