1234567891011121314151617181920212223242526272829303132333435363738394041 |
- using LitJson;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using XRTool.Util;
- public class PrintscreenList : UnitySingleton<PrintscreenList>
- {
- public GameObject printscreenItem;
- public void AddItem(JsonData data)
- {
- string[] strs = data["data"]["src"].ToString().Split(',');
- byte[] bytes = Convert.FromBase64String(strs[strs.Length - 1]);
- int width = int.Parse(data["data"]["width"].ToString());
- int height = int.Parse(data["data"]["height"].ToString());
- Texture2D tex2D = new Texture2D(width, height);
- tex2D.LoadImage(bytes);
- GameObject obj = Instantiate(printscreenItem, RoomFile.Instance.PrintscreenPoint) as GameObject;
- obj.transform.GetComponent<PrintscreenItem>().Init(tex2D);
- obj.transform.localPosition = new Vector3((RoomFile.Instance.fileIndex * 0.8f), 0, 0f);
- obj.transform.eulerAngles = new Vector3(0, RoomFile.Instance.fileIndex * 10, 0);
- string from = data["data"]["from"].ToString();
- if (RoomInfo.Instance && !string.IsNullOrEmpty(from))
- {
- RoomInfo.Instance.ctManager.SetText(from + "发送了截图");
- }
- }
- public void DeleteAll()
- {
- if (transform.childCount > 0)
- {
- for (int i = 0; i < transform.childCount; i++)
- {
- Destroy(transform.GetChild(i).gameObject);
- }
- }
- }
- }
|