public void UseExample() { if (Input.GetMouseButtonDown(0)) { if (Input.mousePosition.x < Screen.width / 3) { //截屏,并将其保存到库/照片 StartCoroutine(TakeScreenshotAndSave()); } else { //如果其他媒体在媒体库中选择照片,则搁置从媒体库中选择照片 if (NativeGallery.IsMediaPickerBusy()) { return; } if (Input.mousePosition.x < Screen.width * 2 / 3) { //从图库/照片中挑选png图片 //Pick a PNG image from Gallery/Photos //如果选择的图片的宽度或高度大于512像素时,缩小图片 // If the selected image's width and/or height is greater than 512px, down-scale the image PickImage(512); } else { //从图库/照片中,选择一个视频 PickVideo(); } } } }
void Update() { if (Input.GetMouseButtonDown(0)) { if (Input.mousePosition.x < Screen.width / 3) { // Take a screenshot and save it to Gallery/Photos StartCoroutine(TakeScreenshotAndSave()); } else { // Don't attempt to pick media from Gallery/Photos if // another media pick operation is already in progress if (NativeGallery.IsMediaPickerBusy()) { return; } if (Input.mousePosition.x < Screen.width * 2 / 3) { // Pick a PNG image from Gallery/Photos // If the selected image's width and/or height is greater than 512px, down-scale the image PickImage(512); } else { // Pick a video from Gallery/Photos PickVideo(); } } } }
/// <summary> /// OnGUI is called for rendering and handling GUI events. /// This function can be called multiple times per frame (one call per event). /// </summary> void OnGUI() { if (GUILayout.Button("Save Galler/Photos", GUILayout.Width(100), GUILayout.Height(100))) { StartCoroutine(TakeScreenshotAndSave()); } if (GUILayout.Button("Pick Image", GUILayout.Width(100), GUILayout.Height(100))) { //另一个媒体选择器占用了进程 if (NativeGallery.IsMediaPickerBusy()) { return; } PickImage(512); } if (GUILayout.Button("Pick Video", GUILayout.Width(100), GUILayout.Height(100))) { //另一个媒体选择器占用了进程 if (NativeGallery.IsMediaPickerBusy()) { return; } PickVideo(); } }
// void Update() //{ //if (Input.GetMouseButtonDown(0)) // { // if (Input.mousePosition.x < Screen.width / 3) // { // Take a screenshot and save it to Gallery/Photos // StartCoroutine(TakeScreenshotAndSave()); // } // else // { // Don't attempt to pick media from Gallery/Photos if // another media pick operation is already in progress //if (NativeGallery.IsMediaPickerBusy()) // return; //if (Input.mousePosition.x < Screen.width * 2 / 3) // { // Pick a PNG image from Gallery/Photos // If the selected image's width and/or height is greater than 512px, down-scale the image // PickImage(512); // } // else // { // Pick a video from Gallery/Photos // PickVideo(); // } // } // } // } public void getPhoto() { if (NativeGallery.IsMediaPickerBusy()) { return; } PickImage(512); }
public void UploadImage() { if (NativeGallery.IsMediaPickerBusy()) { return; } PickImage(512); }
public void UploadVideo() { if (NativeGallery.IsMediaPickerBusy()) { return; } PickVideo(); }
public void OnAvatarButtonClicked() { if (NativeGallery.IsMediaPickerBusy()) { return; } PickImage(512); }
public void OnPictureClick() { Debug.Log("picture has been clicked"); if (NativeGallery.IsMediaPickerBusy()) { return; } PickImage(1024); }
public void LoadClick() { if (NativeGallery.IsMediaPickerBusy()) { return; } PickImage(); }
//갤러리에서 사진을 고르는 함수 public void sajingolra() { if (NativeGallery.IsMediaPickerBusy()) { return; } PickImage(512); }
protected override void OnClick() { if (NativeGallery.IsMediaPickerBusy()) { return; } RecordVideo(); }
public void PickFromGalaryButton() { if (NativeGallery.IsMediaPickerBusy()) { return; } PickImage(512); }
protected override void OnClick() { if (NativeGallery.IsMediaPickerBusy()) { return; } PickImage(512); }
/// <summary> /// Allows the user to select an image from the gallery /// </summary> /// <param name="cN">Name of the campaign</param> public void GetGalleryImage(string cN) { //SceneManager.LoadScene(1); CheckPermissions(); if (NativeGallery.IsMediaPickerBusy()) { return; } PickImage(cN); }
public void start() { if (NativeGallery.IsMediaPickerBusy()) { return; } // Pick a PNG image from Gallery/Photos // If the selected image's width and/or height is greater than 512px, down-scale the image PickImage(780); }
public static void Select(NativeGallery.MediaPickCallback callback) { // Checks that another media pick operation is not already in progress if (!NativeGallery.IsMediaPickerBusy()) { NativeGallery.Permission permission = NativeGallery.GetImageFromGallery(callback, "Select a PNG image", "image/png", _maxSize); Debug.Log("Permission result: " + permission); } }
// Start is called before the first frame update void Start() { Debug.Log("AgTest::Start()"); if (NativeGallery.IsMediaPickerBusy()) { return; } Load100Images(512); //LoadAllImage(16,512); }
public void TakePic() { if (NativeGallery.IsMediaPickerBusy()) { return; } _currentLoadedPicture = null; _fileName = null; //#if UNITY_EDITOR // //System.Windows.Forms.OpenFileDialog openFileDialog; // //openFileDialog = new System.Windows.Forms.OpenFileDialog() // //{ // // InitialDirectory = @"D:\", // // Title = "Browse Text Files", // // CheckFileExists = true, // // CheckPathExists = true, // // DefaultExt = "png", // // Filter = "png files (*.png)|*.jpg", // // FilterIndex = 2, // // RestoreDirectory = true, // // ReadOnlyChecked = true, // // ShowReadOnly = true // //}; // //if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) // //{ // // Debug.Log(openFileDialog.FileName); // // var fileData = System.IO.File.ReadAllBytes(openFileDialog.FileName); // // _currentLoadedPicture = new Texture2D(2, 2); // // _currentLoadedPicture.LoadImage(fileData); //..this will auto-resize the texture dimensions. // // _fileName = openFileDialog.SafeFileName; // //} // OnPictureLoad(_currentLoadedPicture); //#elif UNITY_ANDROID NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((string path) => { if (path != null) { // Create Texture from selected image _currentLoadedPicture = NativeGallery.LoadImageAtPath(path); _fileName = Path.GetFileName(path); OnPictureLoad(_currentLoadedPicture); } }, "", "image/*"); //#endif }
void Button4Click() { // Don't attempt to pick media from Gallery/Photos if // another media pick operation is already in progress if (NativeGallery.IsMediaPickerBusy()) { return; } // Pick a video from Gallery/Photos PickVideo(); }
public void OnChangePhotoButtonClick() { // Don't attempt to pick media from Gallery/Photos if // another media pick operation is already in progress if (NativeGallery.IsMediaPickerBusy()) { return; } // Pick a PNG image from Gallery/Photos // If the selected image's width and/or height is greater than 512px, down-scale the image }
public void ScreenshootButton() { // Deactivate if media picker running; if (NativeGallery.IsMediaPickerBusy()) { return; } // Take screenshot StartCoroutine(TakeScreenShotAndShare()); // Activate the social media buttons panel ViewSocialMediaButtonsPanel(true); }
public void AddPicturesFromGalleryOnClick() { if (NativeGallery.IsMediaPickerBusy()) { return; } if (NativeGallery.CanSelectMultipleFilesFromGallery()) { NativeGallery.GetImagesFromGallery((paths) => HandlePictureAddition(paths), "Select pictures", "image/*"); } else { NativeGallery.GetImageFromGallery((path) => HandlePictureAddition(new[] { path }), "Select picture", "image/*"); } }
void Update() { if (Input.GetMouseButtonDown(0)) { // Don't attempt to pick media from Gallery/Photos if // another media pick operation is already in progress if (NativeGallery.IsMediaPickerBusy()) { return; } else { // Pick a PNG image from Gallery/Photos // If the selected image's width and/or height is greater than 512px, down-scale the image PickImage(512); } } }
/// <summary> /// Pick a PNG image from Gallery/Photos /// If the selected image's width and/or height is greater than 512px, down-scale the image /// uses NativeGallery /// </summary> /// <param name="maxSize">512</param> public void PickImage(int maxSize = 512) { if (NativeGallery.IsMediaPickerBusy()) { return; } NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) => { Debug.Log("Image path: " + path); if (path != null) { PresentPhotoFromPathOnPhone(path, maxSize); } }, "Select a PNG image", "image/png"); Debug.Log("Permission result: " + permission); }
/// <summary> /// Pick a video from Gallery/Photos /// uses NativeGallery /// </summary> public void PickVideo() { if (NativeGallery.IsMediaPickerBusy()) { return; } NativeGallery.Permission permission = NativeGallery.GetVideoFromGallery((path) => { Debug.Log("Video path: " + path); if (path != null) { // Play the selected video Handheld.PlayFullScreenMovie("file://" + path); } }, "Select a video"); Debug.Log("Permission result: " + permission); }
/// <summary> /// Ajoute une interface de calque en demandant de choisir une nouvelle texture. /// </summary> public void AddLayer(Action <Texture2D> callback_) { #if !UNITY_EDITOR if (NativeGallery.CheckPermission() != NativeGallery.Permission.Granted) { if (NativeGallery.RequestPermission() != NativeGallery.Permission.Granted && NativeGallery.CanOpenSettings()) { NativeGallery.OpenSettings(); } else { Application.Quit(); } } if (!NativeGallery.IsMediaPickerBusy()) { var workerObjAFCW_ = AugmentedFaceCreatorWorker.Instance_; var maxSize_ = Mathf.Max(workerObjAFCW_.TextureWidth_, workerObjAFCW_.TextureHeight_); NativeGallery.GetImageFromGallery((path_) => { var texture_ = NativeGallery.LoadImageAtPath(path_, maxSize: maxSize_, markTextureNonReadable: false, generateMipmaps: false); AddLayer(texture_, false, false, true); callback_?.Invoke(texture_); }, title: "Select a texture"); } #else var workerAFCW_ = WorkerObj_.GetComponent <AugmentedFaceCreatorWorker>(); var texture_ = Texture2D.whiteTexture; texture_.Resize(1024, 512); texture_.Apply(); AddLayer(texture_, false, false, true); callback_?.Invoke(texture_); #endif }
public void PickImageFromGalaryButtonRentForm() { imagesURL = "https://kreasarapps.000webhostapp.com/images/"; m_URL = "https://kreasarapps.000webhostapp.com/PropertyBazar/uploadprofilepic.php"; if (pic1 == " " || pic1 == "No Pic") { go = PicImagePlace1; picNumber = 1; } else if (pic2 == " " || pic2 == "No Pic") { go = PicImagePlace2; picNumber = 2; } else if (pic3 == " " || pic3 == "No Pic") { go = PicImagePlace3; picNumber = 3; } else if (pic4 == " " || pic4 == "No Pic") { go = PicImagePlace4; picNumber = 4; } else if (pic5 == " " || pic5 == "No Pic") { go = PicImagePlace5; picNumber = 5; getmoreimages = false; ChooseButton.SetActive(false); } if (NativeGallery.IsMediaPickerBusy()) { return; } PickImage(512); }
public void PickImage(int maxSize) { if (NativeGallery.IsMediaPickerBusy()) { return; } else { maxSize = 1024; NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) => { Debug.Log("Image path: " + path); if (path != null) { Globals.backgroundFile = path; // Create Texture from selected image Texture2D texture = NativeGallery.LoadImageAtPath(path, maxSize); if (texture == null) { Debug.Log("Couldn't load texture from " + path); return; } // Make a readable copy of texture since texture loaded by native gallery is not // The texture must be readable/writeable in order to be applied to a mesh // Source: https://support.unity3d.com/hc/en-us/articles/206486626-How-can-I-get-pixels-from-unreadable-textures- // Create a temporary RenderTexture of the same size as the texture RenderTexture tmp = RenderTexture.GetTemporary( texture.width, texture.height, 0, RenderTextureFormat.Default, RenderTextureReadWrite.Linear); // Blit the pixels on texture to the RenderTexture Graphics.Blit(texture, tmp); // Backup the currently set RenderTexture RenderTexture previous = RenderTexture.active; // Set the current RenderTexture to the temporary one we created RenderTexture.active = tmp; // Create a new readable Texture2D to copy the pixels to it Texture2D myTexture2D = new Texture2D(texture.width, texture.height); // Copy the pixels from the RenderTexture to the new Texture myTexture2D.ReadPixels(new Rect(0, 0, tmp.width, tmp.height), 0, 0); myTexture2D.Apply(); // Reset the active RenderTexture RenderTexture.active = previous; // Release the temporary RenderTexture RenderTexture.ReleaseTemporary(tmp); // "myTexture2D" now has the same pixels from "texture" and it's readable. // Display the selected picture in the background for a preview mySprite = Sprite.Create(myTexture2D, new Rect(0.0f, 0.0f, myTexture2D.width, myTexture2D.height), new Vector2(0.5f, 0.5f), 100.0f); GameObject.Find("Space").GetComponent <Image>().sprite = mySprite; Globals.gameSaved = false; Globals.tex = myTexture2D; } }, "Select a PNG image", "image/png"); Debug.Log("Permission result: " + permission); } }