-
-
Notifications
You must be signed in to change notification settings - Fork 217
Open
Description
Description of the bug
i trie to save the path using Application.persistentDataPath and it work on my pc and if i use google photo, but if i take a photo using NativeCamera.TakePicture or NativeGallery.GetImageFromGallery with the android gallery the serialized path does not work.
here the code
this is the filePyckerSystem
private void Start()
{
FinalPath = "";
Permission = NativeFilePicker.Permission.Granted;
GalleryPermission = NativeGallery.Permission.Granted;
CameraPermission = NativeCamera.Permission.Granted;
}
public void LoadFiles()
{
string FileType = NativeFilePicker.ConvertExtensionToFileType("png,jpg,jpeg");
if (Permission == NativeFilePicker.Permission.Granted && GalleryPermission == NativeGallery.Permission.Granted)
{
NativeGallery.GetImageFromGallery((path) =>
{
if (path == null)
{
Debug.Log("no file");
text.text = " no file";
}
else
{
FinalPath = path;
Debug.Log("file : " + FinalPath);
text.text = FinalPath;
LoadImageFromGallery();
FinalPath = "";
}
}, FileType);
}
}
public void TakePicture()
{
if (NativeCamera.IsCameraBusy() || !NativeCamera.DeviceHasCamera())
{
Debug.Log("No camera or busy");
return;
}
if (CameraPermission == NativeCamera.Permission.Granted)
{
NativeCamera.Permission permission = NativeCamera.TakePicture((path) =>
{
Debug.Log("Image path: " + path);
if (path != null)
{
FinalPath = path;
Debug.Log("file : " + FinalPath);
text.text = FinalPath;
LoadImageFromCamera();
FinalPath = "";
}
else
{
Debug.Log("no file");
text.text = " no file";
}
}, 0);
}
}
void LoadImageFromGallery()
{
button.interactable = false;
Texture2D texture = NativeGallery.LoadImageAtPath(FinalPath, NativeGallery.GetImageProperties(FinalPath).width);
button.interactable = true;
NamePrefab.transform.GetChild(6).GetComponent<Image>().sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100, 0, SpriteMeshType.FullRect, Vector4.zero, false);
NamePrefab.transform.GetChild(8).GetComponent<TMP_Text>().text = FinalPath;
//NativeGallery.SaveImageToGallery(texture, FinalPath,"Image.png", ( success, path ) => Debug.Log( "Media save result: " + success + " " + path ));
}
void LoadImageFromCamera()
{
button.interactable = false;
Texture2D texture = NativeCamera.LoadImageAtPath(FinalPath, NativeCamera.GetImageProperties(FinalPath).width);
button.interactable = true;
NamePrefab.transform.GetChild(6).GetComponent<Image>().sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100, 0, SpriteMeshType.FullRect, Vector4.zero, false);
NamePrefab.transform.GetChild(8).GetComponent<TMP_Text>().text = FinalPath;
}
for the save i just put i a json file some variables between here a string with the path.
- Unity version: e.g. 2022.3.29f1
- Platform: *Android
- Device: *OPPO A74 5g
- How did you download the plugin: Package Managere
thanks in advance ( sorry for theEnglish not my native language)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels