private void FinishGetTexture(Texture2D texture2D) { Texture2D t2d = ConvertTool.ConvertToTexture2d(texture2D); rawardPor.sprite = ConvertTool.ConvertToSpriteWithTexture2d(t2d); byte[] bts = t2d.EncodeToPNG(); imgData = ConvertTool.bytesToString(bts); }
private void CallBackSelectTexture(Texture2D value) { if (value.height > 128 || value.width > 128) { AndaUIManager.Instance.PlayTips("请保存选择的图像为128大小"); Destroy(value); return; } Texture2D newT2d = ConvertTool.ConvertToTexture2d(value); porImg.sprite = ConvertTool.ConvertToSpriteWithTexture2d(newT2d); imgValue = newT2d.EncodeToPNG(); }
public void GetUserImg(string path, System.Action <Sprite> action) { string s = PlayerPrefs.GetString("SH_" + path); if (s == "") { CallServerGetUserImg(path, action); } else { byte[] vs = ConvertTool.StringToBytes(s); Texture2D texture = new Texture2D(128, 128); texture.LoadImage(vs); texture = ConvertTool.ConvertToTexture2d(texture); Sprite sprite = ConvertTool.ConvertToSpriteWithTexture2d(texture); action(sprite); } }
private IEnumerator ExcuteCallServerGetRewardImagePor(string adress, System.Action <Sprite> callback) { AndaUIManager.Instance.OpenWaitBoard(true); WWW wWW = new WWW(adress); yield return(wWW); AndaUIManager.Instance.OpenWaitBoard(false); if (string.IsNullOrEmpty(wWW.error)) { byte[] b = wWW.texture.EncodeToPNG(); string t = ConvertTool.bytesToString(b); PlayerPrefs.SetString("RW_" + adress, t); Texture2D texture2D = ConvertTool.ConvertToTexture2d(wWW.texture); Sprite sprite = ConvertTool.ConvertToSpriteWithTexture2d(texture2D); callback(sprite); } else { AndaUIManager.Instance.PlayTips(wWW.error); } }