Example #1
0
        void Setup()
        {
            if (imagePick == null)
            {
                imagePick = SmartMonoBehaviour.FindOrCreate <ImagePicker>();
            }

            //if(data == null)
            {
                data            = new ImagePickerData();
                data.fileSubDir = subDir;
                data.maxHeight  = 512;
                data.maxWidth   = 512;
                data.quality    = -1; //force png's so we can get transparant items
                data.bestFit    = true;

                data.showCamera = showCam;
                data.useDefault = useDefault;

                data.gameObject    = imagePick.name;
                data.callback      = imagePick.ImagePickerCallback;
                data.callbackError = OnError;

                //data.fileType = "image/png"; //we could change it to Mime Types like */* or image/png, make sure you test any changes in this, as it might lead to segmentation faults if misused.
                //only mimetypes that start with "image" will be copied and resized, other files will be returned as a path to their original location
            }

            StartCoroutine(ScanForFile());
        }
Example #2
0
        /// <summary>
        /// Get a single image from a movie (must be supported on the device)
        /// The preview image is processed just as through StartImagePicker
        /// </summary>
        /// <param name="ImagePickerData"></param>
        public void GetVideoPreview(ImagePickerData data, string videoPath)
        {
            processing = data;
#if DEFAULT_ACTIVITY
            imagePicker.CallStatic("getVideoPreview", currentActivity, data.setting, receivedFilePath);
#else
            ajcImagePicker.CallStatic("getVideoPreview", data.setting, videoPath);
#endif
        }
Example #3
0
        /// <summary>
        /// Request the first received file from the array of received files
        /// </summary>
        /// <param name="image">a non-null image to load the new texture into</param>
        /// <param name="fileName">filename to save the selected image into</param>
        /// <param name="subDir">subdir to save the selected image into</param>
        /// <param name="maxWidth">maximum width the image will be downscaled to</param>
        /// <param name="maxHeight">maximum height the image will be downscaled to</param>
        /// <param name="bestFit">false: simple downscale, true: downscale to either maxWidth or maxHeight where both are below max</param>
        public void ReceiveFile(Texture2D image, string fileName, string subDir, int maxWidth, int maxHeight, bool bestFit)
        {
            ImagePickerData data = new ImagePickerData(image, null, subDir, maxWidth, maxHeight, bestFit);

            data.callback   = ImagePickerReceive;
            data.gameObject = gameObject.name;

            ReceiveFile(data, 0);
        }
Example #4
0
 internal void Start()
 {
     data = new ImagePickerData();
     {
         data.loadImage  = image;
         data.fileName   = null;
         data.gameObject = gameObject.name;
         data.callback   = ImagePickerCallback;
     }
 }
Example #5
0
        /// <summary>
        /// Request the first received file from the array of received files
        /// </summary>
        /// <param name="imageSetter">a System.Action that receives a texture</param>
        /// <param name="fileName">filename to save the selected image into</param>
        /// <param name="subDir">subdir to save the selected image into</param>
        /// <param name="maxWidth">maximum width the image will be downscaled to</param>
        /// <param name="maxHeight">maximum height the image will be downscaled to</param>
        /// <param name="bestFit">false: simple downscale, true: downscale to either maxWidth or maxHeight where both are below max</param>
        public void ReceiveFile(System.Action <Texture2D> imageSetter, string fileName, string subDir, int maxWidth, int maxHeight, bool bestFit)
        {
            ImagePickerData data = new ImagePickerData(null, null, subDir, maxWidth, maxHeight, bestFit);

            data.callback    = ImagePickerReceive;
            data.gameObject  = gameObject.name;
            data.imageSetter = imageSetter;

            ReceiveFile(data, 0);
        }
Example #6
0
        /// <summary>
        /// Start the Image Picker Activity
        /// </summary>
        /// <param name="image">a non-null image to load the new texture into</param>
        /// <param name="subDir">subdir to save the selected image into</param>
        /// <param name="maxWidth">maximum width the image will be downscaled to</param>
        /// <param name="maxHeight">maximum height the image will be downscaled to</param>
        /// <param name="bestFit">false: simple downscale, true: downscale to either maxWidth or maxHeight where both are below max</param>
        /// <param name="showCamera">true: add Camera apps to picker, false: no camera apps</param>
        public void StartImagePicker(System.Action <Texture2D> imageSetter, string fileName, string subDir, int maxWidth, int maxHeight, bool bestFit, bool showCamera = false)
        {
            ImagePickerData data = new ImagePickerData(null, fileName, subDir, maxWidth, maxHeight, bestFit, showCamera);

            //these two are set for conveniance
            data.gameObject  = gameObject.name;
            data.callback    = ImagePickerCallback;
            data.imageSetter = imageSetter;

            StartImagePicker(data);
        }
Example #7
0
        /// <summary>
        /// Receive all files from the Image Picker Activity
        /// Optinally clear the list when done processing the list
        /// Note: no additional checks are done if the list was added to after Unity receives the last expected entry
        /// </summary>
        /// <param name="imageSetter">system action for setting multiple textures</param>
        /// <param name="fileName">filename to save the selected image into</param>
        /// <param name="subDir">subdir to save the selected image into</param>
        /// <param name="maxWidth">maximum width the image will be downscaled to</param>
        /// <param name="maxHeight">maximum height the image will be downscaled to</param>
        /// <param name="bestFit">false: simple downscale, true: downscale to either maxWidth or maxHeight where both are below max</param>
        /// <param name="removeReceived">true: after all images are done, clear the received items list</param>
        public void ReceiveAllFiles(System.Action <Texture2D> imageSetter, string fileName, string subDir, int maxWidth, int maxHeight, bool bestFit, bool removeProcessed)
        {
            ImagePickerData data = new ImagePickerData(null, fileName, subDir, maxWidth, maxHeight, bestFit);

            data.imageSetter    = imageSetter;
            data.removeReceived = removeProcessed;

            //these two are set for conveniance
            data.gameObject = gameObject.name;
            data.callback   = ImagePickerReceive;

            ReceiveAllFiles(data);
        }
Example #8
0
        /// <summary>
        /// Start the Image Picker Activity
        /// </summary>
        /// <param name="data">a populated ImagePickerData</param>
        /// <param name="callbackHandler">unique object name to call the function on</param>
        /// <param name="function">delegate compatible function</param>
        public void StartImagePicker(ImagePickerData data, GameObject callbackHandler, ImageResultFunc function)
        {
            processing = data;

            data.gameObject = callbackHandler.name;
            data.callback   = function;

#if DEFAULT_ACTIVITY
            imagePicker.CallStatic("selectImage", currentActivity, data.setting);
#else
            ajcImagePicker.CallStatic("selectImage", data.setting);
#endif
        }
Example #9
0
        /// <summary>
        /// Example image loader
        /// </summary>
        /// <param name="file"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        public static IEnumerator LoadImage(string file, ImagePickerData data)
        {
            WWW www = new WWW(@"file://" + file);

            yield return(www);

            if (string.IsNullOrEmpty(www.error))
            {
                www.LoadImageIntoTexture(data.loadImage);
            }
            else
            {
                Debug.LogError(www.error);
            }
        }
Example #10
0
        /// <summary>
        /// Start the Image Picker Activity
        /// </summary>
        /// <param name="data">a populated ImagePickerData</param>
        public void StartImagePicker(ImagePickerData data)
        {
            processing = data;

            //it needs a texture before it can load
            if (data.imageSetter == null && data.loadImage == null)
            {
                data.loadImage = new Texture2D(1, 1);
            }

#if DEFAULT_ACTIVITY
            imagePicker.CallStatic("selectImage", currentActivity, data.setting);
#else
            ajcImagePicker.CallStatic("selectImage", data.setting);
#endif
        }
        public override void Start()
        {
            base.Start();
            if (items > 0)
            {
                items = 0;
            }
#if !UNITY_EDITOR || DEBUG
            imagePicker = GetOrCreateComponent <ImagePicker>(this);

            data            = new ImagePickerData(null, null, "Gallery", 512, 512, true, true);
            data.gameObject = gameObject.name;
            data.callback   = CustomeReceiver;
#endif
            lookAt = Camera.main.transform;
        }
Example #12
0
        /// <summary>
        /// Start the Image Picker Activity
        /// </summary>
        /// <param name="image">a non-null image to load the new texture into</param>
        /// <param name="fileName">filename to save the selected image into</param>
        /// <param name="subDir">subdir to save the selected image into</param>
        /// <param name="maxWidth">maximum width the image will be downscaled to</param>
        /// <param name="maxHeight">maximum height the image will be downscaled to</param>
        /// <param name="bestFit">false: simple downscale, true: downscale to either maxWidth or maxHeight where both are below max</param>
        /// <param name="showCamera">true: add Camera apps to picker, false: no camera apps</param>
        public void StartImagePicker(Texture2D image, string fileName, string subDir, int maxWidth, int maxHeight, bool bestFit, bool showCamera = false)
        {
            ImagePickerData data = new ImagePickerData();//image, fileName, subDir, maxWidth, maxHeight, bestFit, showCamera);

            data.loadImage = image;

            data.bestFit    = bestFit;
            data.showCamera = showCamera;
            data.fileName   = fileName;
            data.fileSubDir = subDir;
            data.maxWidth   = maxWidth;
            data.maxHeight  = maxHeight;

            data.useDefault = false;

            //these two are set for conveniance
            data.gameObject = gameObject.name;
            data.callback   = ImagePickerCallback;

            StartImagePicker(data);
        }
Example #13
0
 /// <summary>
 /// Open an image from a known external location and cache it
 ///
 /// This is usefull if you have a way of finding / selecting files within your Unity3D scenes
 /// And wish to process those files before allowing them to load.
 /// You could add these to the initial loading from the external cache to prevent problems when the User adds files manually to the directory.
 /// If those files are unsupported by Unity3D unexpected behaviour may occur, symptoms may include but are not limited to:
 /// - unable to load all images
 /// - chrashing the android video driver
 ///
 /// Note:
 /// It is more efficient to load received files by index.
 ///
 /// </summary>
 /// <param name="data"></param>
 /// <param name="filepath"></param>
 public void ProcessImage(ImagePickerData data, string filepath)
 {
     processing = data;
     ajcImagePicker.CallStatic("openFile", data.setting, filepath);
 }
Example #14
0
 /// <summary>
 /// Load received images according to data, if fileName is set it will be appended with auto increment
 ///
 /// Examples:
 /// fileName null = use original filenames
 ///
 /// fileName "img_" = calls the callback with images stored as img, img_2, img_3, etc...
 /// according to compression setting either PNG (< 0) or JPG (0 - 100) will be added as extension
 ///
 /// if filetype begins with "image/"
 /// the plugin will callback with an empty path for each invalid entry
 /// while debugging check the logcat for more information on each file
 /// upon receiving a empty string, you should just inform the user that an image did not load succesfully.
 ///
 /// </summary>
 public void ReceiveAllFiles(ImagePickerData data)
 {
     processing = data;
     ajcImagePicker.CallStatic("receiveAllFiles", data.setting);
 }
Example #15
0
 /// <summary>
 /// Request a specific received file from the array of received files
 /// </summary>
 /// <param name="data">settings for loading the image</param>
 /// <param name="file">the index to attempt to load, 0 based</param>
 public void ReceiveFile(ImagePickerData data, int index)
 {
     processing = data;
     //the plugin will handle checking if the index is valid
     ajcImagePicker.CallStatic("receiveFile", data.setting, index);
 }