PrintscreenList.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using LitJson;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using UnityEngine;
  6. using XRTool.Util;
  7. public class PrintscreenList : UnitySingleton<PrintscreenList>
  8. {
  9. public GameObject printscreenItem;
  10. public void AddItem(JsonData data)
  11. {
  12. string[] strs = data["data"]["src"].ToString().Split(',');
  13. byte[] bytes = Convert.FromBase64String(strs[strs.Length - 1]);
  14. int width = int.Parse(data["data"]["width"].ToString());
  15. int height = int.Parse(data["data"]["height"].ToString());
  16. Texture2D tex2D = new Texture2D(width, height);
  17. tex2D.LoadImage(bytes);
  18. GameObject obj = Instantiate(printscreenItem, RoomFile.Instance.PrintscreenPoint) as GameObject;
  19. obj.transform.GetComponent<PrintscreenItem>().Init(tex2D);
  20. obj.transform.localPosition = new Vector3((RoomFile.Instance.fileIndex * 0.8f), 0, 0f);
  21. obj.transform.eulerAngles = new Vector3(0, RoomFile.Instance.fileIndex * 10, 0);
  22. string from = data["data"]["from"].ToString();
  23. if (RoomInfo.Instance && !string.IsNullOrEmpty(from))
  24. {
  25. RoomInfo.Instance.ctManager.SetText(from + "发送了截图");
  26. }
  27. }
  28. public void DeleteAll()
  29. {
  30. if (transform.childCount > 0)
  31. {
  32. for (int i = 0; i < transform.childCount; i++)
  33. {
  34. Destroy(transform.GetChild(i).gameObject);
  35. }
  36. }
  37. }
  38. }