67 lines
1.4 KiB
C#
67 lines
1.4 KiB
C#
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using System.Collections;
|
|||
|
|
|||
|
using System.IO;
|
|||
|
|
|||
|
public class ImageSelectPanel : MonoBehaviour
|
|||
|
{
|
|||
|
|
|||
|
public Image _ShowingPhoto;
|
|||
|
public Sprite _DefaultSprite;
|
|||
|
public Text _Title;
|
|||
|
|
|||
|
private ImageManagerRoot.CuttedPhoto _CuttedPhotoCallback;
|
|||
|
private Texture2D _CuttedTexture;
|
|||
|
|
|||
|
public void OnBtnClose()
|
|||
|
{
|
|||
|
gameObject.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
#region opt
|
|||
|
|
|||
|
public void InitImage()
|
|||
|
{
|
|||
|
_ShowingPhoto.sprite = _DefaultSprite;
|
|||
|
}
|
|||
|
|
|||
|
public void CuttedPhotoCallBack(Texture2D orgPhoto)
|
|||
|
{
|
|||
|
_CuttedTexture = orgPhoto;
|
|||
|
_ShowingPhoto.sprite = Sprite.Create(_CuttedTexture, new Rect(0, 0, _CuttedTexture.width, _CuttedTexture.height), new Vector2(0.5f, 0.5f));
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
public void SetImageCallBack(ImageManagerRoot.CuttedPhoto cuttedCallBack, string title)
|
|||
|
{
|
|||
|
_Title.text = title;
|
|||
|
InitImage();
|
|||
|
gameObject.SetActive(true);
|
|||
|
_CuttedPhotoCallback = cuttedCallBack;
|
|||
|
}
|
|||
|
|
|||
|
public void OnBtnPhoto()
|
|||
|
{
|
|||
|
ImageManagerRoot.ShowImageCutStatic(CuttedPhotoCallBack);
|
|||
|
}
|
|||
|
|
|||
|
public void OnBtnCamera()
|
|||
|
{
|
|||
|
ImageManagerRoot.ShowImageCameraStatic(CuttedPhotoCallBack);
|
|||
|
}
|
|||
|
|
|||
|
public void OnBtnOk()
|
|||
|
{
|
|||
|
gameObject.SetActive(false);
|
|||
|
|
|||
|
if (_CuttedPhotoCallback != null && _CuttedTexture != null)
|
|||
|
{
|
|||
|
_CuttedPhotoCallback(_CuttedTexture);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
}
|