|
@@ -65,9 +65,27 @@ namespace GFGGame
|
|
|
Debug.Log("文件路径:" + path);
|
|
|
Texture2D tex = this.viewData as Texture2D;
|
|
|
byte[] bytes = tex.EncodeToPNG();//将纹理数据,转化成一个png图片
|
|
|
- File.WriteAllBytes(path + "/Pictures/wanshijing/" + fileName, bytes);
|
|
|
- GetSaveState(path);
|
|
|
+ var filePath = path + "/Pictures/wanshijing/" + fileName;
|
|
|
+ File.WriteAllBytes(filePath, bytes);
|
|
|
+ //GetSaveState(path);
|
|
|
+ savePngAndUpdate(filePath);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ //调用iOS或Android原生方法保存图片后更新相册.
|
|
|
+ private void savePngAndUpdate(string fileName)
|
|
|
+ {
|
|
|
+#if UNITY_ANDROID
|
|
|
+ GetAndroidJavaObject().Call("scanFile", fileName, "保存成功辣٩(๑>◡<๑)۶ "); //这里我们可以设置保存成功弹窗内容
|
|
|
+#endif
|
|
|
+ }
|
|
|
+
|
|
|
+ //用于获取Android原生方法类对象
|
|
|
+ private AndroidJavaObject GetAndroidJavaObject()
|
|
|
+ {
|
|
|
+ return new AndroidJavaObject("com.example.saveimagelibrary.SaveImageActivity"); //设置成我们aar库中的签名+类名
|
|
|
+ }
|
|
|
+
|
|
|
private void GetSaveState(string path)
|
|
|
{
|
|
|
|