Example #1
0
        private IEnumerator OpenFile()
        {
            string photoPath = string.Empty;

#if UNITY_EDITOR
            Utils.DisplayWarning(
                "Select .jpg or .png selfie photo",
                "Please select frontal photo of a person in .jpg or .png format. Works best on smartphone selfies (iPhone, Samsung, etc.)"
                );
            photoPath = EditorUtility.OpenFilePanelWithFilters("Select .jpg selfie photo", "", new string[] {
                "Selfie",
                "jpg,jpeg,png"
            });
#elif UNITY_ANDROID
            AndroidImageSupplier imageSupplier = new AndroidImageSupplier();
            yield return(imageSupplier.GetImageFromStorageAsync());

            photoPath = imageSupplier.FilePath;
#elif UNITY_IOS
            IOSImageSupplier imageSupplier = IOSImageSupplier.Create();
            yield return(imageSupplier.GetImageFromStorageAsync());

            photoPath = imageSupplier.FilePath;
#endif
            if (string.IsNullOrEmpty(photoPath))
            {
                yield break;
            }
            byte[] bytes = File.ReadAllBytes(photoPath);
            if (fileHandler != null)
            {
                yield return(fileHandler(bytes));
            }
        }
        public IEnumerator CaptureImageFromCameraAsync()
        {
            FilePath  = string.Empty;
            gotResult = false;

            IOSImageSupplier.getPhoto(gameObjectName, "onResult");

            while (!gotResult)
            {
                yield return(new WaitForEndOfFrame());
            }
        }