Exemplo n.º 1
0
        private void PickImageFinished(ePickImageFinishReason _finishReason, Texture2D _image)
        {
            // Update properties
            image.Value = _image;

            // Invoke appropriate event
            switch (_finishReason)
            {
            case ePickImageFinishReason.SELECTED:
                Fsm.Event(selectedEvent);
                break;

            case ePickImageFinishReason.CANCELLED:
                Fsm.Event(cancelledEvent);
                break;

            case ePickImageFinishReason.FAILED:
                Fsm.Event(failedEvent);
                break;

            default:
                Log("[MediaLibrary] Unhandled reason.");
                break;
            }

            Finish();
        }
		protected void PickImageFinished (string _imagePath, ePickImageFinishReason _finishReason)
		{
			// Resume unity player
			this.ResumeUnity();
			
			Console.Log(Constants.kDebugTag, "[MediaLibrary] Finishing pick image, Path=" + _imagePath + " Reason=" + _finishReason);
			if (OnPickImageFinished != null)
			{
				// Failed opertation
				if (_finishReason != ePickImageFinishReason.SELECTED)
				{
					OnPickImageFinished(_finishReason, null);
					return;
				}
				
				// Download image from given path
				URL _imagePathURL				= URL.FileURLWithPath(_imagePath);
				DownloadTexture _newDownload	= new DownloadTexture(_imagePathURL, true, true);
				_newDownload.OnCompletion		= (Texture2D _texture, string _error)=>{
					
					if (string.IsNullOrEmpty(_error))
					{
						OnPickImageFinished(ePickImageFinishReason.SELECTED, _texture);
					}
					else
					{
						Console.LogError(Constants.kDebugTag, "[MediaLibrary] Texture download failed, URL=" + _imagePathURL.URLString);
						OnPickImageFinished(ePickImageFinishReason.FAILED, null);
					}
				};
				
				// Start download
				_newDownload.StartRequest();
			}
		}	
Exemplo n.º 3
0
        protected void PickImageFinished(string _imagePath, ePickImageFinishReason _finishReason)
        {
            // Resume unity player
            this.ResumeUnity();

            Console.Log(Constants.kDebugTag, "[MediaLibrary] Finishing pick image, Path=" + _imagePath + " Reason=" + _finishReason);
            if (OnPickImageFinished != null)
            {
                // Failed opertation
                if (_finishReason != ePickImageFinishReason.SELECTED)
                {
                    OnPickImageFinished(_finishReason, null);
                    return;
                }

                // Download image from given path
                URL             _imagePathURL = URL.FileURLWithPath(_imagePath);
                DownloadTexture _newDownload  = new DownloadTexture(_imagePathURL, true, true);
                _newDownload.OnCompletion = (Texture2D _texture, string _error) => {
                    if (string.IsNullOrEmpty(_error))
                    {
                        OnPickImageFinished(ePickImageFinishReason.SELECTED, _texture);
                    }
                    else
                    {
                        Console.LogError(Constants.kDebugTag, "[MediaLibrary] Texture download failed, URL=" + _imagePathURL.URLString);
                        OnPickImageFinished(ePickImageFinishReason.FAILED, null);
                    }
                };

                // Start download
                _newDownload.StartRequest();
            }
        }
Exemplo n.º 4
0
 private void PickImageFinished(ePickImageFinishReason _reason, Texture2D _image)
 {
     Debug.Log("Reason = " + _reason);
     Debug.Log("Texture = " + _image);
     CharacterImage.sprite = Sprite.Create(_image, CharacterImage.rectTransform.rect, CharacterImage.rectTransform.pivot);
     SaveTextureToFile(_image, _image.name);
 }
		protected override void ParsePickImageFinishedData (IDictionary _infoDict, out string _selectedImagePath, out ePickImageFinishReason _finishReason)
		{
			_selectedImagePath	= _infoDict.GetIfAvailable<string>(kImagePath);
			_finishReason		=  kPickImageParseMap[_infoDict.GetIfAvailable<string>(kFinishReason)];
			
			// Selected image path is invalid
			if (string.IsNullOrEmpty(_selectedImagePath))
			{
				_selectedImagePath	= null;
				_finishReason		= ePickImageFinishReason.FAILED;
			}
		}
	private void PickImageFinished (ePickImageFinishReason _reason, Texture2D _image)
	{
		string reasonString = _reason + "";
		if (reasonString == "SELECTED") {
			GMS.showLoading (true);
			image = _image;
			imageTexture.renderer.material.mainTexture = image;
		
			GMS.userData.temp_img = GMS.generateId ().ToString () + ".png";
		
			StartCoroutine (GMS.saveTextureToFile (imageTexture.renderer.material.mainTexture as Texture2D, GMS.userData.temp_img, 'u'));
			StartCoroutine (loadImage ());
		}
	}
Exemplo n.º 7
0
    private void PickImageFinished(ePickImageFinishReason _reason, Texture2D _image)
    {
        string reasonString = _reason + "";

        if (reasonString == "SELECTED")
        {
            GMS.showLoading(true);
            image = _image;
            imageTexture.renderer.material.mainTexture = image;

            GMS.userData.temp_img = GMS.generateId().ToString() + ".png";

            StartCoroutine(GMS.saveTextureToFile(imageTexture.renderer.material.mainTexture as Texture2D, GMS.userData.temp_img, 'u'));
            StartCoroutine(loadImage());
        }
    }
Exemplo n.º 8
0
        protected void PickImageFinished(string _imagePath, ePickImageFinishReason _finishReason)
        {
            // Resume unity player
            this.ResumeUnity();
            DebugUtility.Logger.Log(Constants.kDebugTag, "[MediaLibrary] Finishing pick image, Path=" + _imagePath + " Reason=" + _finishReason);
            if (OnPickImageFinished != null)
            {
                // Failed opertation
                if (_finishReason != ePickImageFinishReason.SELECTED)
                {
                    OnPickImageFinished(_finishReason, null);
                    return;
                }

                // Download image from given path
                URL             _imagePathURL = URL.FileURLWithPath(_imagePath);
                DownloadTexture _newDownload  = new DownloadTexture(_imagePathURL, Application.platform != RuntimePlatform.Android, true);                   //On Android, we consider the exif orientation in native code for performance.
                _newDownload.ScaleFactor  = m_scaleFactor;
                _newDownload.OnCompletion = (Texture2D _texture, string _error) => {
#if !UNITY_EDITOR
                    // Delete the file
                    if (!string.IsNullOrEmpty(_imagePath))
                    {
                        FileOperations.Delete(_imagePath);
                    }
#endif

                    if (string.IsNullOrEmpty(_error))
                    {
                        OnPickImageFinished(ePickImageFinishReason.SELECTED, _texture);
                    }
                    else
                    {
                        DebugUtility.Logger.LogError(Constants.kDebugTag, "[MediaLibrary] Texture download failed, URL=" + _imagePathURL.URLString);
                        OnPickImageFinished(ePickImageFinishReason.FAILED, null);
                    }
                };

                // Start download
                _newDownload.StartRequest();
            }
        }
Exemplo n.º 9
0
    private void PickImageFinished(ePickImageFinishReason _reason, Texture2D _image)
    {
        string reasonString = _reason + "";

        Debug.Log("Reason: " + reasonString);
        Debug.Log("Textura: " + _image);


        if (reasonString == "SELECTED")
        {
            Debug.Log("Entro al loop de foto seleccionada");
            GMS.showLoading(true);
            imageTexture.renderer.material.mainTexture = _image;
            newImageNameId = GMS.generateId().ToString();
            newImageName   = newImageNameId + ".png";
            StartCoroutine(GMS.saveTextureToFile(_image, newImageName, 'g'));
            StartCoroutine(setPinctureContinue());
        }
        else
        {
            GMS.showLoading(false);
        }
    }
Exemplo n.º 10
0
 protected virtual void ParsePickImageFinishedData(IDictionary _infoDict, out string _selectedImagePath, out ePickImageFinishReason _finishReason)
 {
     // Default values
     _selectedImagePath = null;
     _finishReason      = ePickImageFinishReason.FAILED;
 }
 private void PickImageFinished(ePickImageFinishReason _reason, Texture2D _image)
 {
     AddNewResult("Image picker was closed");
     AppendResult("Reason = " + _reason);
     AppendResult("Texture Image = " + _image);
 }
Exemplo n.º 12
0
 private void PickImageFinished(ePickImageFinishReason _reason, Texture2D _image)
 {
     AddNewResult("Request to pick image from gallery finished. Reason for finish is " + _reason + ".");
     AppendResult(string.Format("Selected image is {0}.", (_image == null ? "NULL" : _image.ToString())));
     m_texture = _image;
 }
		protected virtual void ParsePickImageFinishedData (IDictionary _infoDict, out string _selectedImagePath, out ePickImageFinishReason _finishReason)
		{
			// Default values
			_selectedImagePath	= null;
			_finishReason		= ePickImageFinishReason.FAILED;
		}
Exemplo n.º 14
0
 protected override void ParsePickImageFinishedData(IDictionary _infoDict, out string _selectedImagePath, out ePickImageFinishReason _finishReason)
 {
     _selectedImagePath = _infoDict.GetIfAvailable <string>(kImagePath);
     _finishReason      = (ePickImageFinishReason)_infoDict.GetIfAvailable <int>(kFinishReason);
 }
Exemplo n.º 15
0
 private void PickImageFinished(ePickImageFinishReason _reason, Texture2D _image)
 {
     AddNewResult("Image picker was closed");
     AppendResult("Reason = " + _reason);
     AppendResult("Texture Image = " + _image);
 }
		protected override void ParsePickImageFinishedData (IDictionary _infoDict, out string _selectedImagePath, out ePickImageFinishReason _finishReason)
		{
			_selectedImagePath	= _infoDict.GetIfAvailable<string>(kImagePath);
			_finishReason		=  (ePickImageFinishReason)_infoDict.GetIfAvailable<int>(kFinishReason);
		}
Exemplo n.º 17
0
        protected override void ParsePickImageFinishedData(IDictionary _infoDict, out string _selectedImagePath, out ePickImageFinishReason _finishReason)
        {
            _selectedImagePath = _infoDict.GetIfAvailable <string>(kImagePath);
            _finishReason      = kPickImageParseMap[_infoDict.GetIfAvailable <string>(kFinishReason)];

            // Selected image path is invalid
            if (string.IsNullOrEmpty(_selectedImagePath))
            {
                _selectedImagePath = null;
                _finishReason      = ePickImageFinishReason.FAILED;
            }
        }
		private void PickImageFinished (ePickImageFinishReason _reason, Texture2D _image)
		{
			AddNewResult("Request to pick image from gallery finished. Reason for finish is " + _reason + ".");
			AppendResult(string.Format("Selected image is {0}.", (_image == null ? "NULL" : _image.ToString())));
		}