Пример #1
0
 public void OnOpenGalleryButtonClicked()
 {
     NativeGalleryController.OpenGallery((Texture2D tex, ExifOrientation orientation) => {
         orientationLabel.text = "Orientation: " + orientation;
         ShowTexture(tex);
     });
 }
Пример #2
0
 void Update()
 {
     if (_instance == null)
     {
         _instance = this;
     }
 }
Пример #3
0
        public static void OpenGallery(System.Action <Texture2D, ExifOrientation> callback, bool rotateImportedImage, Tastybits.NativeGallery.ImagePickerType iOSImagePickerType)
        {
            if (NativeGalleryController.Verbose)
            {
                Debug.Log("Opening Image Picker");
            }
            _callback = callback;

#if UNITY_IPHONE && !UNITY_EDITOR
            if (NativeGalleryController.Verbose)
            {
                Debug.Log("Opening Image Picker - iOS");
            }
            UIImagePicker.OpenPhotoAlbum((Texture2D texture, bool ok, string errMsg) => {
                _callback(texture, UIImagePicker.GetLastImportedOrientation());
            }, rotateImportedImage, iOSImagePickerType);
#elif UNITY_ANDROID && !UNITY_EDITOR
            if (NativeGalleryController.Verbose)
            {
                Debug.Log("Opening Image Picker - Android");
            }
            AndroidGallery.OpenGallery((Texture2D tex) => {
                _callback(tex, AndroidGallery.GetLastImportedOrientation());
            }, rotateImportedImage);
#elif UNITY_EDITOR
            if (NativeGalleryController.Verbose)
            {
                Debug.Log("Opening Image Picker - Editor");
            }
            NativeGalleryController.OpenEditorGallery(callback);
#else
            Debug.LogError("OpenGallery: Function not implemented for platform " + Application.platform);
#endif
        }
Пример #4
0
 void OnDestroy()
 {
     if (_instance == this)
     {
         _instance = null;
     }
 }
Пример #5
0
        /**
         * In the Unity Editor we can support recompile by using Update.
         */
#if UNITY_EDITOR
        void Update()
        {
            if (_instance == null && iAmSingleton)
            {
                _instance = this;
            }
        }
        /**
         *
         * Initializese the component and makes sure that no more than 1 instance is created.
         *
         */

        void Awake()
        {
            if (_instance != null && _instance != this)
            {
                Debug.LogWarning("The gameobject : " + this.name + " was destroyed since there is already an insteance of the Native Gallery Component loaded");

                GameObject.DestroyImmediate(this.gameObject);

                return;
            }

            Object.DontDestroyOnLoad(this.gameObject);

            if (_instance == null)
            {
                _instance = this;
            }

            if (Time.frameCount < 3)
            {
                instance.gameObject.SetActive(false);
            }

            iAmSingleton = true;
        }
Пример #7
0
 void Awake()
 {
     _instance = this;
     if (Time.frameCount < 3)
     {
         _instance.gameObject.SetActive(false);
     }
 }
Пример #8
0
        public static void OpenGallery(System.Action <Texture2D> callback)
        {
            _callback = callback;

#if UNITY_IPHONE && !UNITY_EDITOR
            UIImagePicker.OpenPhotoAlbum((Texture2D texture, bool ok, string errMsg) => {
                _callback(texture);
            });
#elif UNITY_ANDROID && !UNITY_EDITOR
            AndroidGallery.OpenGallery((Texture2D tex) => {
                _callback(tex);
            });
#elif UNITY_EDITOR
            NativeGalleryController.OpenEditorGallery(callback);
#else
            Debug.LogError("OpenGallery: Function not implemented for platform " + Application.platform);
#endif
        }
Пример #9
0
 public void OnOpenGalleryButtonClicked()
 {
     NativeGalleryController.OpenGallery(( Texture2D tex ) => {
         ShowTexture(tex);
     });
 }