每日自动提交 2026-04-13 18:30
This commit is contained in:
+160
-52
@@ -1,67 +1,126 @@
|
||||
using System.Collections;
|
||||
using Assets.Framework.Tool;
|
||||
using Assets.MyGame.Scripts.Net;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UIUserInfo : UIBase
|
||||
public class UIUserInfo : SubUIBase
|
||||
{
|
||||
// public Button btn_CloseBtn;
|
||||
// public Button btn_Title;
|
||||
// public Text txt_YinPiao;
|
||||
// public Text txt_Name;
|
||||
// Image img_Title;
|
||||
// [Header("TitleChangePanel")]
|
||||
// public GameObject obj_TitlePrefab;
|
||||
// public Transform tra_TitleParent;
|
||||
public Button btn_CloseBtn;
|
||||
public Button btn_Title;
|
||||
public Text txt_YinPiao;
|
||||
public Text txt_Name;
|
||||
Image img_Title;
|
||||
[Header("TitleChangePanel")]
|
||||
public GameObject obj_TitlePrefab;
|
||||
public Transform tra_TitleParent;
|
||||
|
||||
// //public void AddImage()
|
||||
// //{
|
||||
// // NativeGallery.GetImageFromGallery((path) =>
|
||||
// // {
|
||||
// // Debug.Log(path);
|
||||
// // if (string.IsNullOrEmpty(path))
|
||||
// // {
|
||||
// // Debug.LogError("未选择图片");
|
||||
// // return;
|
||||
// // }
|
||||
//public void AddImage()
|
||||
//{
|
||||
// NativeGallery.GetImageFromGallery((path) =>
|
||||
// {
|
||||
// Debug.Log(path);
|
||||
// if (string.IsNullOrEmpty(path))
|
||||
// {
|
||||
// Debug.LogError("未选择图片");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // // 回调里不能 yield,所以启动协程
|
||||
// // StartCoroutine(DownloadTextureWithRetry(path, 5, (tex) =>
|
||||
// // {
|
||||
// // if (tex != null)
|
||||
// // {
|
||||
// // 回调里不能 yield,所以启动协程
|
||||
// StartCoroutine(DownloadTextureWithRetry(path, 5, (tex) =>
|
||||
// {
|
||||
// if (tex != null)
|
||||
// {
|
||||
|
||||
// // Debug.Log("Image Down Ok");
|
||||
// // StartCoroutine(DefaultTools.UploadingImage(DataManager.Instance.settingData.uid.ToString(), tex.EncodeToPNG()));
|
||||
// // //WebSocketManager.Instance.SendMessageToUrl(UrlType.defaultType, new { CMD = 11011, avatar_id = tex.EncodeToPNG() });
|
||||
// // // TODO: 使用 tex
|
||||
// // //DataManager.Instance.myPlayerInfo.titleSprite = Sprite.Create(tex, new Rect(0, 0, 110, 110), new Vector2(0.5f, 0.5f));
|
||||
// Debug.Log("Image Down Ok");
|
||||
// StartCoroutine(DefaultTools.UploadingImage(DataManager.Instance.settingData.uid.ToString(), tex.EncodeToPNG()));
|
||||
// //WebSocketManager.Instance.SendMessageToUrl(UrlType.defaultType, new { CMD = 11011, avatar_id = tex.EncodeToPNG() });
|
||||
// // TODO: 使用 tex
|
||||
// //DataManager.Instance.myPlayerInfo.titleSprite = Sprite.Create(tex, new Rect(0, 0, 110, 110), new Vector2(0.5f, 0.5f));
|
||||
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // UIManager.Instance.ShowLog("图片下载失败 5 次");
|
||||
// // }
|
||||
// // }));
|
||||
// // });
|
||||
// //}
|
||||
// //public RawImage previewImage; // 用来显示裁剪后的头像
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// UIManager.Instance.ShowLog("图片下载失败 5 次");
|
||||
// }
|
||||
// }));
|
||||
// });
|
||||
//}
|
||||
//public RawImage previewImage; // 用来显示裁剪后的头像
|
||||
public void ShowChoiceDialog()
|
||||
{
|
||||
|
||||
}
|
||||
public Button btnA, btnB;
|
||||
public Text textTitleLabel;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// public void ShowChoiceDialog(string label, string btnTXTA,string btnTXTB, UnityAction actionA, UnityAction actionB)
|
||||
// {
|
||||
// textTitleLabel.transform.parent.gameObject.SetActive(true);
|
||||
// btnA.onClick.RemoveAllListeners();
|
||||
// btnB.onClick.RemoveAllListeners();
|
||||
// btnA.GetComponentInChildren<Text>().text = btnTXTA;
|
||||
// btnB.GetComponentInChildren<Text>().text = btnTXTB;
|
||||
// btnA.onClick.AddListener(actionA);
|
||||
// btnA.onClick.AddListener(() =>
|
||||
// {
|
||||
// textTitleLabel.transform.parent.gameObject.SetActive(false);
|
||||
// });
|
||||
// btnB.onClick.AddListener(actionB);
|
||||
// btnB.onClick.AddListener(() =>
|
||||
// {
|
||||
// textTitleLabel.transform.parent.gameObject.SetActive(false);
|
||||
// });
|
||||
// textTitleLabel.text = label;
|
||||
// }
|
||||
// public void AddImage()
|
||||
// {
|
||||
// NativeGallery.GetImageFromGallery((path) =>
|
||||
// {
|
||||
// if (string.IsNullOrEmpty(path))
|
||||
// // 弹出一个选择框,用户可以选择拍照或者从相册选择
|
||||
// // 这里用简单的按钮逻辑,你可以替换成自己的 UI
|
||||
// ShowChoiceDialog("选择图片来源", "拍照", "相册",
|
||||
// () =>
|
||||
// {
|
||||
// Debug.LogError("未选择图片");
|
||||
// return;
|
||||
// // 拍照
|
||||
// NativeCamera.TakePicture((path) =>
|
||||
// {
|
||||
// if (!string.IsNullOrEmpty(path))
|
||||
// {
|
||||
// StartCoroutine(LoadAndCropImage(path));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Debug.LogError("未拍摄图片");
|
||||
// }
|
||||
// });
|
||||
// },
|
||||
// () =>
|
||||
// {
|
||||
// // 相册
|
||||
// NativeGallery.GetImageFromGallery((path) =>
|
||||
// {
|
||||
// if (!string.IsNullOrEmpty(path))
|
||||
// {
|
||||
// StartCoroutine(LoadAndCropImage(path));
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Debug.LogError("未选择图片");
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// // 启动协程加载图片
|
||||
// StartCoroutine(LoadAndCropImage(path));
|
||||
// });
|
||||
// );
|
||||
// }
|
||||
// private IEnumerator LoadAndCropImage(string path)
|
||||
// {
|
||||
@@ -78,8 +137,7 @@ public class UIUserInfo : UIBase
|
||||
// if (result && croppedImage != null)
|
||||
// {
|
||||
// // 创建一个新的可读纹理副本
|
||||
// Texture2D readableTex = new Texture2D(croppedImage.width, croppedImage.height, TextureFormat.RGBA32, false);
|
||||
// Graphics.CopyTexture(croppedImage, readableTex); // 复制像素数据到可读纹理
|
||||
// Texture2D readableTex = MakeReadable(croppedImage);
|
||||
|
||||
// // 显示裁剪后的图片
|
||||
// btn_Title.GetComponent<Image>().sprite = Sprite.Create(
|
||||
@@ -111,6 +169,43 @@ public class UIUserInfo : UIBase
|
||||
// }
|
||||
// }
|
||||
|
||||
// //private Texture2D MakeReadable(Texture2D src)
|
||||
// //{
|
||||
// // RenderTexture rt = RenderTexture.GetTemporary(src.width, src.height, 0, RenderTextureFormat.Default, RenderTextureReadWrite.Linear);
|
||||
// // Graphics.Blit(src, rt);
|
||||
|
||||
// // RenderTexture previous = RenderTexture.active;
|
||||
// // RenderTexture.active = rt;
|
||||
|
||||
// // Texture2D readableTex = new Texture2D(src.width, src.height, TextureFormat.RGBA32, false);
|
||||
// // readableTex.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0);
|
||||
// // readableTex.Apply();
|
||||
|
||||
// // RenderTexture.active = previous;
|
||||
// // RenderTexture.ReleaseTemporary(rt);
|
||||
|
||||
// // return readableTex;
|
||||
// //}
|
||||
// private Texture2D MakeReadable(Texture2D src)
|
||||
// {
|
||||
// // 使用默认 RenderTextureFormat,避免 Linear/Gamma 不匹配
|
||||
// RenderTexture rt = RenderTexture.GetTemporary(src.width, src.height, 0, RenderTextureFormat.Default);
|
||||
// Graphics.Blit(src, rt);
|
||||
|
||||
// RenderTexture previous = RenderTexture.active;
|
||||
// RenderTexture.active = rt;
|
||||
|
||||
// Texture2D readableTex = new Texture2D(src.width, src.height, TextureFormat.RGBA32, false);
|
||||
// readableTex.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0);
|
||||
// readableTex.Apply();
|
||||
|
||||
// RenderTexture.active = previous;
|
||||
// RenderTexture.ReleaseTemporary(rt);
|
||||
|
||||
// return readableTex;
|
||||
// }
|
||||
|
||||
|
||||
// private IEnumerator DownloadTextureWithRetry(string url, int retryCount, System.Action<Texture2D> callback)
|
||||
// {
|
||||
// //url = "file://" + url;
|
||||
@@ -155,9 +250,22 @@ public class UIUserInfo : UIBase
|
||||
// public void Init()
|
||||
// {
|
||||
// img_Title = btn_Title.GetComponent<Image>();
|
||||
// img_Title.sprite = DataManager.Instance.myPlayerInfo.titleSprite;
|
||||
// if (GameManager.Instance.user.BaseInfo.avatarSprite==null)
|
||||
// {
|
||||
// WebTool.DownImage(APIManager.baseURL + GameManager.Instance.user.BaseInfo.avatarUrl, (texture) =>
|
||||
// {
|
||||
// GameManager.Instance.user.BaseInfo.avatarSprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
|
||||
// img_Title.sprite = GameManager.Instance.user.BaseInfo.avatarSprite;
|
||||
// });
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// img_Title.sprite = GameManager.Instance.user.BaseInfo.avatarSprite;
|
||||
|
||||
// }
|
||||
|
||||
// //img_Title.sprite= Resources.Load<Sprite>("TitleImg/" + DataManager.Instance.myPlayerInfo.image);
|
||||
// txt_Name.name = DataManager.Instance.myPlayerInfo.name;
|
||||
// txt_Name.name = GameManager.Instance.user.BaseInfo.userName;
|
||||
// //读取
|
||||
// foreach (Sprite item in Resources.LoadAll<Sprite>("TitleImg"))
|
||||
// {
|
||||
|
||||
Reference in New Issue
Block a user