|
@@ -2,6 +2,7 @@
|
|
|
using System.Collections;
|
|
|
using System.Collections.Generic;
|
|
|
using System.IO;
|
|
|
+using OpenCVForUnity.CoreModule;
|
|
|
using TMPro;
|
|
|
using TriLibCore;
|
|
|
using UnityEngine;
|
|
@@ -10,128 +11,119 @@ using static XunJianDataManager;
|
|
|
|
|
|
public class RenWuTypeWindow : MonoBehaviour
|
|
|
{
|
|
|
- public RenWuTypeModel data;
|
|
|
|
|
|
public MinioResources data2;
|
|
|
|
|
|
public TextMeshProUGUI info;
|
|
|
Texture2D tex;
|
|
|
|
|
|
- public void updateData(RenWuTypeModel data)
|
|
|
- {
|
|
|
- if(tex!=null)
|
|
|
- {
|
|
|
- Destroy(tex);
|
|
|
- }
|
|
|
- this.data = data;
|
|
|
- switch(data.type)
|
|
|
- {
|
|
|
- case RenWuType.Video:
|
|
|
- DownLoadXRManager.DownLoadForFilePath(DownLoadXRManager.getTestData(data.url), (string bytes) => {
|
|
|
- this.GetComponent<ShowVideoManager>().url = bytes;
|
|
|
- }, (float f) => {
|
|
|
-
|
|
|
-
|
|
|
- });
|
|
|
- break;
|
|
|
- case RenWuType.Text:
|
|
|
- this.gameObject.GetComponentInChildren<TextMeshProUGUI>().text = data.info;
|
|
|
- break;
|
|
|
- case RenWuType.Image:
|
|
|
- DownLoadXRManager.DownLoadForTexture(DownLoadXRManager.getTestData(data.url), (Texture2D bytes) => {
|
|
|
-
|
|
|
- tex = bytes;
|
|
|
- this.GetComponent<RawImage>().texture = tex;
|
|
|
- }, (float f) => {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- });
|
|
|
- break;
|
|
|
- case RenWuType.Model:
|
|
|
- DownLoadXRManager.DownLoadForFilePath(DownLoadXRManager.getTestData(data.url),(string bytes)=> {
|
|
|
- info.gameObject.SetActive(false);
|
|
|
- this.GetComponent<ShowModelManager>().Onupdate(bytes);
|
|
|
- },(float f)=> {
|
|
|
-
|
|
|
-
|
|
|
- info.gameObject.SetActive(true);
|
|
|
- info.text = "模型下载中" + f.ToString("F2") + "%";
|
|
|
- });
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
private void OnEnable()
|
|
|
{
|
|
|
-
|
|
|
this.transform.GetComponent<RectTransform>().anchoredPosition3D = Vector3.zero;
|
|
|
this.transform.GetComponent<RectTransform>().localEulerAngles = Vector3.zero;
|
|
|
this.transform.GetComponent<RectTransform>().localScale = Vector3.one;
|
|
|
- }
|
|
|
|
|
|
- public void updateData(MinioResources data)
|
|
|
+ if(data2.loadingMethod==1)
|
|
|
+ {
|
|
|
+
|
|
|
+ changebizhi(this.GetComponent<RawImage>().texture);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ Mat _mat;
|
|
|
+ public void updateData(MinioResources datafile)
|
|
|
{
|
|
|
+ Debug.Log("updateData=====>4444");
|
|
|
if (tex != null)
|
|
|
{
|
|
|
Destroy(tex);
|
|
|
}
|
|
|
- this.data2 = data;
|
|
|
+ this.data2 = datafile;
|
|
|
|
|
|
|
|
|
- switch (data.loadingMethod)
|
|
|
+ switch (data2.loadingMethod)
|
|
|
{
|
|
|
case 11111:
|
|
|
- this.gameObject.GetComponentInChildren<TextMeshProUGUI>().text = data.info;
|
|
|
+ Debug.Log("updateData=====>5555");
|
|
|
+ info.text = data2.info;
|
|
|
+ Debug.Log("updateData=====>66666");
|
|
|
break;
|
|
|
case 3:
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ this.GetComponent<ShowVideoManager>().OnDisable();
|
|
|
info.gameObject.SetActive(true);
|
|
|
info.text = "视频加载中";
|
|
|
- this.GetComponent<RawImage>().enabled = false;
|
|
|
- RoomFileMinio.Instance.getFile(RoomFileMinio.Instance.bucket, data.path, rfd =>
|
|
|
+ if (File.Exists(Application.persistentDataPath + "/" + data2.uuid + Path.GetExtension(data2.path)))
|
|
|
{
|
|
|
info.gameObject.SetActive(false);
|
|
|
- info.text = "视频加载中";
|
|
|
+ info.text = "";
|
|
|
this.GetComponent<RawImage>().enabled = true;
|
|
|
- Debug.Log(rfd.url);
|
|
|
- Debug.Log(rfd.bytes.Length);
|
|
|
-
|
|
|
- WindowsManager.Instance.StartCoroutine(SaveMp4(Application.persistentDataPath + "/" + data.uuid + Path.GetExtension(data.path), rfd.bytes));
|
|
|
+ WindowsManager.Instance.StartCoroutine(SaveMp4(Application.persistentDataPath + "/" + data2.uuid + Path.GetExtension(data2.path), null));
|
|
|
|
|
|
- });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
+ this.GetComponent<RawImage>().enabled = false;
|
|
|
+ RoomFileMinio.Instance.getFile(RoomFileMinio.Instance.bucket, data2.path, data2.uuid, rfd =>
|
|
|
+ {
|
|
|
+ info.gameObject.SetActive(false);
|
|
|
+ info.text = "视频加载中";
|
|
|
+ this.GetComponent<RawImage>().enabled = true;
|
|
|
+ if (this.data2.path == rfd.objectName)
|
|
|
+ {
|
|
|
+
|
|
|
+ WindowsManager.Instance.StartCoroutine(SaveMp4(Application.persistentDataPath + "/" + data2.uuid + Path.GetExtension(data2.path), rfd.bytes));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
break;
|
|
|
case -1:
|
|
|
|
|
|
break;
|
|
|
case 1:
|
|
|
-
|
|
|
+ if (File.Exists(Application.persistentDataPath + "/" + data2.uuid + Path.GetExtension(data2.path)))
|
|
|
+ {
|
|
|
+ Loom.RunAsync(() =>
|
|
|
+ {
|
|
|
+ _mat = GameUtility.zoomByteByOpenCV(Application.persistentDataPath + "/" + data2.uuid + Path.GetExtension(data2.path) ,1, false, true);
|
|
|
+ Loom.QueueOnMainThread(() => {
|
|
|
+ if (tex != null)
|
|
|
+ {
|
|
|
+ Destroy(tex);
|
|
|
+ }
|
|
|
+ tex = GameUtility.TextureByMat(_mat);
|
|
|
+ this.GetComponent<RawImage>().texture = tex;
|
|
|
+ changebizhi(tex);
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ RoomFileMinio.Instance.getFile(RoomFileMinio.Instance.bucket, data2.path, data2.uuid, rfd =>
|
|
|
+ {
|
|
|
+ Debug.Log("RoomFileMinio.Instance.bucket=End===>");
|
|
|
+ Debug.Log(rfd.url);
|
|
|
+ Debug.Log(rfd.bytes.Length);
|
|
|
+ Texture2D tex = GetSprite(rfd.bytes).texture;
|
|
|
+ this.GetComponent<RawImage>().texture = tex;
|
|
|
+ changebizhi(tex);
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ Stream sw = File.Create(Application.persistentDataPath + "/" + data2.uuid + Path.GetExtension(data2.path));
|
|
|
+
|
|
|
|
|
|
- Debug.Log("RoomFileMinio.Instance.bucket====>" + RoomFileMinio.Instance.bucket);
|
|
|
- Debug.Log("RoomFileMinio.Instance.bucket=data.path===>" + data.path);
|
|
|
- RoomFileMinio.Instance.getFile(RoomFileMinio.Instance.bucket, data.path, rfd =>
|
|
|
- {
|
|
|
- Debug.Log("RoomFileMinio.Instance.bucket=End===>" );
|
|
|
- Debug.Log(rfd.url);
|
|
|
- Debug.Log(rfd.bytes.Length);
|
|
|
+ sw.Write(rfd.bytes, 0, rfd.bytes.Length);
|
|
|
|
|
|
- this.GetComponent<RawImage>().texture = GetSprite(rfd.bytes).texture;
|
|
|
- });
|
|
|
+ sw.Close();
|
|
|
+ sw.Dispose();
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
break;
|
|
|
case 2:
|
|
|
|
|
@@ -143,71 +135,79 @@ public class RenWuTypeWindow : MonoBehaviour
|
|
|
|
|
|
|
|
|
|
|
|
- RoomFileMinio.Instance.getFile(RoomFileMinio.Instance.bucket, data.path, rfd =>
|
|
|
+
|
|
|
+ if (info )
|
|
|
+ {
|
|
|
+ info.text = "准备加载";
|
|
|
+ }
|
|
|
+ if (this.GetComponent<ShowModelManager>().root != null)
|
|
|
+ {
|
|
|
+ Destroy(this.GetComponent<ShowModelManager>().root);
|
|
|
+ this.GetComponent<ShowModelManager>().root = null;
|
|
|
+ }
|
|
|
+ if(File.Exists(Application.persistentDataPath + "/" + data2.uuid + Path.GetExtension(data2.path)))
|
|
|
{
|
|
|
- Debug.Log(rfd.url);
|
|
|
- Debug.Log(rfd.bytes.Length);
|
|
|
-
|
|
|
- WindowsManager.Instance.StartCoroutine(SaveModel(Application.persistentDataPath + "/" + data.uuid +Path.GetExtension( data.path), rfd.bytes));
|
|
|
- });
|
|
|
+ WindowsManager.Instance.StartCoroutine(SaveModel(Application.persistentDataPath + "/" + data2.uuid + Path.GetExtension(data2.path), null));
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ RoomFileMinio.Instance.getFile(RoomFileMinio.Instance.bucket, data2.path, data2.uuid, rfd =>
|
|
|
+ {
|
|
|
+
|
|
|
+ if (this.data2.path == rfd.objectName)
|
|
|
+ {
|
|
|
+ WindowsManager.Instance.StartCoroutine(SaveModel(Application.persistentDataPath + "/" + data2.uuid + Path.GetExtension(data2.path), rfd.bytes));
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
break;
|
|
|
}
|
|
|
+ Debug.Log("updateData=====>88888");
|
|
|
}
|
|
|
|
|
|
- private IEnumerator SaveMp4(string path, byte[] bytes)
|
|
|
+ public void changebizhi(Texture tex)
|
|
|
{
|
|
|
- Debug.Log(" Path ==> " + path);
|
|
|
- FileInfo file = new FileInfo(path);
|
|
|
- if (file.Exists)
|
|
|
+
|
|
|
+ float bz = 1;
|
|
|
+ float bzbz = 640f / 480f;
|
|
|
+
|
|
|
+ if (tex.width > tex.height)
|
|
|
{
|
|
|
-
|
|
|
- yield return new WaitForSeconds(0.02f);
|
|
|
- this.GetComponent<ShowVideoManager>().url = path;
|
|
|
- if(JinRuRenwu.Instance.Video.activeSelf)
|
|
|
- this.GetComponent<ShowVideoManager>().playeVideo();
|
|
|
+ bz = tex.height/480f ;
|
|
|
+
|
|
|
+ Debug.Log(" bizhi====>"+ bz);
|
|
|
+ this.transform.localScale = new Vector3(1, bz/ (float)(tex.width / 640f), 1);
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- Stream sw = File.Create(path);
|
|
|
-
|
|
|
-
|
|
|
- sw.Write(bytes, 0, bytes.Length);
|
|
|
+ bz = tex.width/640f ;
|
|
|
+ Debug.Log(" bizhi====>" + bz );
|
|
|
+ this.transform.localScale = new Vector3(bz/ (float)(tex.height / 480f), 1, 1);
|
|
|
|
|
|
- sw.Close();
|
|
|
- sw.Dispose();
|
|
|
- yield return new WaitForSeconds(0.02f);
|
|
|
- this.GetComponent<ShowVideoManager>().url = path;
|
|
|
- if (JinRuRenwu.Instance.Video.activeSelf)
|
|
|
- this.GetComponent<ShowVideoManager>().playeVideo();
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- private IEnumerator SaveModel(string path, byte[] bytes)
|
|
|
+ private IEnumerator SaveMp4(string path, byte[] bytes)
|
|
|
{
|
|
|
- Debug.Log(" Path ==> " + path);
|
|
|
- FileInfo file = new FileInfo(path);
|
|
|
- if (file.Exists)
|
|
|
- {
|
|
|
-
|
|
|
- yield return new WaitForSeconds(0.02f);
|
|
|
- this.GetComponent<ShowModelManager>().Onupdate(path);
|
|
|
+ this.GetComponent<ShowVideoManager>().url = path;
|
|
|
+ if (JinRuRenwu.Instance.Video.activeSelf)
|
|
|
+ this.GetComponent<ShowVideoManager>().playeVideo();
|
|
|
+
|
|
|
+ yield return new WaitForSeconds(0.02f);
|
|
|
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- Stream sw = File.Create(path);
|
|
|
-
|
|
|
+ }
|
|
|
|
|
|
- sw.Write(bytes, 0, bytes.Length);
|
|
|
|
|
|
- sw.Close();
|
|
|
- sw.Dispose();
|
|
|
- yield return new WaitForSeconds(0.02f);
|
|
|
+ private IEnumerator SaveModel(string path, byte[] bytes)
|
|
|
+ {
|
|
|
+ info.text = "";
|
|
|
this.GetComponent<ShowModelManager>().Onupdate(path);
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
+ yield return new WaitForSeconds(0.02f);
|
|
|
}
|
|
|
|
|
|
private Sprite GetSprite(Byte[] bytes)
|
|
@@ -216,7 +216,7 @@ public class RenWuTypeWindow : MonoBehaviour
|
|
|
Texture2D texture = new Texture2D(10, 10);
|
|
|
texture.LoadImage(bytes);
|
|
|
|
|
|
- Sprite sp = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
|
|
|
+ Sprite sp = Sprite.Create(texture, new UnityEngine.Rect(0, 0, texture.width, texture.height), Vector2.zero);
|
|
|
return sp;
|
|
|
}
|
|
|
}
|