|
@@ -2,6 +2,7 @@ using System;
|
|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using UnityEngine;
|
|
|
+using UnityEngine.Networking;
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
public class SPJK_ObsItem : MonoBehaviour
|
|
@@ -11,6 +12,53 @@ public class SPJK_ObsItem : MonoBehaviour
|
|
|
public Text typeText;
|
|
|
public Text codeText;
|
|
|
public Text updataTimeText;
|
|
|
+
|
|
|
+ public RawImage fm;
|
|
|
+
|
|
|
+ public static Dictionary<string, Texture> OBSTexLibrary = new Dictionary<string, Texture>();
|
|
|
+
|
|
|
+ private void Start()
|
|
|
+ {
|
|
|
+ ActionInstance._Instance.obsFmUpdata += OnGetFmUpdate;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void OnDestroy()
|
|
|
+ {
|
|
|
+ ActionInstance._Instance.obsFmUpdata -= OnGetFmUpdate;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void OnEnable()
|
|
|
+ {
|
|
|
+ if (!havePic && _data != null) {
|
|
|
+ // Debug.Log(_data.targetName);
|
|
|
+ string hashName = ObsPlayerPanel.GetHashedName(_data.targetName);
|
|
|
+ StartCoroutine(LoadFmTex(ServerAddress.Server_TextureSavePath + hashName + ".jpg"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ private void OnGetFmUpdate(string name)
|
|
|
+ {
|
|
|
+ if (name.Equals(ObsPlayerPanel.GetHashedName(_data.targetName)))
|
|
|
+ {
|
|
|
+ StartCoroutine(LoadFmTex(ServerAddress.Server_TextureSavePath + name + ".jpg"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ bool havePic = false;
|
|
|
+ IEnumerator LoadFmTex(string url)
|
|
|
+ {
|
|
|
+ UnityWebRequest www = UnityWebRequestTexture.GetTexture(url);
|
|
|
+ yield return www.SendWebRequest();
|
|
|
+ string hashName = ObsPlayerPanel.GetHashedName(_data.targetName);
|
|
|
+ if (www.isDone && www.result == UnityWebRequest.Result.Success)
|
|
|
+ {
|
|
|
+ fm.texture = ((DownloadHandlerTexture)www.downloadHandler).texture;
|
|
|
+ havePic = true;
|
|
|
+ if (!OBSTexLibrary.ContainsKey(ServerAddress.Server_TextureSavePath + hashName + ".jpg"))
|
|
|
+ OBSTexLibrary.Add(ServerAddress.Server_TextureSavePath + hashName + ".jpg", fm.texture);
|
|
|
+ }
|
|
|
+ www.disposeDownloadHandlerOnDispose = true;
|
|
|
+ www.Dispose();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
public void SetData(ObsData data)
|
|
|
{
|
|
@@ -25,6 +73,9 @@ public class SPJK_ObsItem : MonoBehaviour
|
|
|
typeText.text = "分类:<color=#FFFFFF>套口</color>";
|
|
|
break;
|
|
|
}
|
|
|
- codeText.text = $"编码:<color=#FFFFFF>{_data.channelId}</color>";;
|
|
|
+ codeText.text = $"编码:<color=#FFFFFF>{_data.channelId}</color>";
|
|
|
+
|
|
|
+ string hashName = ObsPlayerPanel.GetHashedName(_data.targetName);
|
|
|
+ StartCoroutine(LoadFmTex( ServerAddress.Server_TextureSavePath + hashName + ".jpg"));
|
|
|
}
|
|
|
}
|