Browse Source

COS 下载修改

DGJ 1 year ago
parent
commit
95d7196a48

+ 2 - 0
Assets/2.0/Tools/DownLoadItem.cs

@@ -246,6 +246,8 @@ public class DownLoadItem : MonoBehaviour
         data.localLoadPath = Application.persistentDataPath + "/Material/" + Path.GetFileName(downLoadPath);
         data.updataTime = 0;
         data.type = type.ToString();
+
+        Debug.LogError("DownloadFileMsg");
         DownloadResManager.Instance.DownLoad(data);
     }
 

+ 2 - 0
Assets/2.0/Tools/LoadManager.cs

@@ -15,6 +15,7 @@ public class LoadManager : Singleton<LoadManager>
             if (downloadQueueList.Count>0&& nowLoad< maxLoad)
             {
                 int ct = downloadQueueList.Count;
+                Debug.LogError("  downloadQueueList =====>   " + ct);
                 for (int i = 0; i < ct; i++)
                 {
                     DownLoadItem item = downloadQueueList.Dequeue();
@@ -48,6 +49,7 @@ public class LoadManager : Singleton<LoadManager>
     public void load(ModelItem model, Action<float> onProgress, Action<GameObject> callback)
     {
         string dName = getLoadName(model.url, model.Version);
+        Debug.Log("dName ======>   " + dName);
         if (!downList.ContainsKey(dName))
         {
             GameObject obj = new GameObject(dName);

+ 4 - 4
Assets/2.0/User/Model/ModelItem.cs

@@ -44,8 +44,8 @@ public class ModelItem
 
     public void init()
     {
-
-        if (modelType != ModelType.Video)
+        Debug.LogError("ModelItem Init");
+       // if (modelType != ModelType.Video)
             LoadManager.Instance.load(this, (float f) =>
             {
 
@@ -61,8 +61,8 @@ public class ModelItem
               //  obj.transform.localEulerAngles = getInfoEul(); 
 
             });
-        else
-            SetData(null);
+      //  else
+       //     SetData(null);
     }
 
 

+ 8 - 3
Assets/2.0/User/Model/ModelList.cs

@@ -1,6 +1,7 @@
 using SC.XR.Unity.Module_InputSystem;
 using System.Collections;
 using System.Collections.Generic;
+using System.IO;
 using UnityEngine;
 using XRTool.Util;
 
@@ -61,8 +62,11 @@ public class ModelList: System.ICloneable
             initModelObj();
         }
         _model.SetActive(isAdd);
-
-        if(isAdd)
+        //for (int i = 0; i < materialList.Count; i++)
+        //{
+        //    materialList[i].init();
+        //}
+        if (isAdd)
         {
             for (int i = 0; i < materialList.Count; i++)
             {
@@ -182,7 +186,8 @@ public class ModelList: System.ICloneable
                     var pVideo = ResMgr.Instance.Load<GameObject>("Template/Prefab/Video");
                     go = GameObject.Instantiate(pVideo, spoit.transform);                   
                     go.SetActive(true);
-                    go.AddComponent<TemplateVideo>();
+                    TemplateVideo video = go.AddComponent<TemplateVideo>();
+                    video.localSavePath = Application.persistentDataPath + "/Material/" + Path.GetFileName(objs[i].DownloadPath);
                     //var videoitem = go.AddComponent<TemplateVideo>();
                     //videoitem.SetData(mat, material.updateTime);
                     break;

+ 1 - 0
Assets/2.0/User/Model/ModelManager.cs

@@ -66,6 +66,7 @@ public class ModelManager : Singleton<ModelManager>
         {
             Debug.Log("modelList.Model==>"+ modelList.Model.name);
             modelList.materialList[j].init(modelList.Model);
+          //  DownLoadModel(modelList);
         }
     }
 

+ 120 - 49
Assets/COSScripts/COSDownLoad.cs

@@ -17,9 +17,19 @@ using Newtonsoft.Json.Linq;
 
 public class COSDownLoad:MonoSingleton<COSDownLoad>
 {
-    public SuccessCOS successCos;
-    QCloudCredentialProvider cosCredentialProvider;
-    CosXml cosXml;
+
+    /*
+     *  根据下载的类型  分为   -1 Scene  Materail -2 vuforial
+     * 
+     */
+
+    public SuccessCOS materialSuccessCos;
+    public SuccessCOS sceneSuccessCos;
+    public SuccessCOS imageSuccessCos;
+  //  QCloudCredentialProvider cosCredentialProvider;
+    CosXml materialCosXml;
+    CosXml sceneCosXml;
+    CosXml imageCosXml;
     // Start is called before the first frame update
 
    public void Credential()
@@ -28,41 +38,108 @@ public class COSDownLoad:MonoSingleton<COSDownLoad>
         credential.type = "material";
         string data = JsonConvert.SerializeObject(credential);
         Debug.Log(data);
-        HttpTool.Instance.Post("/storage/credential/create", data, CredentialCallBack);
+        HttpTool.Instance.Post("/storage/credential/create", data, CredentialMaterialCallBack);
+
+        Credential credential2 = new Credential();
+        credential2.type = "scene";
+        string data2 = JsonConvert.SerializeObject(credential2);
+        HttpTool.Instance.Post("/storage/credential/create", data2, CredentialSceneCallBack);
+
+        Credential credential3 = new Credential();
+        credential3.type = "image";
+        string data3 = JsonConvert.SerializeObject(credential3);
+        HttpTool.Instance.Post("/storage/credential/create", data3, CredentialImageCallBack);
+
+    }
+
+    private void InitMaterialCos()
+    {
+        CosXmlConfig config = new CosXmlConfig.Builder()
+            .IsHttps(true)
+            .SetRegion(materialSuccessCos.region)
+            .SetDebugLog(true)
+            .Build();
+        QCloudCredentialProvider cosCredentialProvider  = new DefaultSessionQCloudCredentialProvider(
+ materialSuccessCos.credentials.tmpSecretId, materialSuccessCos.credentials.tmpSecretKey, materialSuccessCos.expiredTime, materialSuccessCos.credentials.sessionToken);
+
+        materialCosXml = new CosXmlServer(config, cosCredentialProvider);
+
+    }
+
+    private void InitImageCos()
+    {
+        CosXmlConfig config = new CosXmlConfig.Builder()
+            .IsHttps(true)
+            .SetRegion(imageSuccessCos.region)
+            .SetDebugLog(true)
+            .Build();
+        QCloudCredentialProvider cosCredentialProvider = new DefaultSessionQCloudCredentialProvider(
+ imageSuccessCos.credentials.tmpSecretId, imageSuccessCos.credentials.tmpSecretKey, imageSuccessCos.expiredTime, imageSuccessCos.credentials.sessionToken);
+
+        imageCosXml = new CosXmlServer(config, cosCredentialProvider);
     }
 
-    private void InitCos()
+    private void InitSceneCos()
     {
         CosXmlConfig config = new CosXmlConfig.Builder()
             .IsHttps(true)
-            .SetRegion(successCos.region)
+            .SetRegion(sceneSuccessCos.region)
             .SetDebugLog(true)
             .Build();
-        cosCredentialProvider  = new DefaultSessionQCloudCredentialProvider(
- successCos.credentials.tmpSecretId, successCos.credentials.tmpSecretKey, successCos.expiredTime, successCos.credentials.sessionToken);
+        QCloudCredentialProvider cosCredentialProvider = new DefaultSessionQCloudCredentialProvider(
+ sceneSuccessCos.credentials.tmpSecretId, sceneSuccessCos.credentials.tmpSecretKey, sceneSuccessCos.expiredTime, sceneSuccessCos.credentials.sessionToken);
 
-        cosXml = new CosXmlServer(config, cosCredentialProvider);
+        sceneCosXml = new CosXmlServer(config, cosCredentialProvider);
+    }
 
+    private void CredentialMaterialCallBack( string msg)
+    {
+        Debug.Log(msg);
+        JObject jObject = JObject.Parse(msg);
 
-     //  StartCoroutine( MaterialManager.Instance.GetAllMaterials(UserInfo.Instance.Token));
+        if (jObject["code"].ToString() == "200")
+        {
+            materialSuccessCos = JsonConvert.DeserializeObject<SuccessCOS>(jObject["data"].ToString());
+            InitMaterialCos();
+        }
+        else
+        {
+            Debug.LogError(msg);
+        }
     }
 
-    private void CredentialCallBack( string msg)
+    private void CredentialSceneCallBack(string msg)
     {
         Debug.Log(msg);
         JObject jObject = JObject.Parse(msg);
 
         if (jObject["code"].ToString() == "200")
         {
-            successCos = JsonConvert.DeserializeObject<SuccessCOS>(jObject["data"].ToString());
-            InitCos();
+            sceneSuccessCos = JsonConvert.DeserializeObject<SuccessCOS>(jObject["data"].ToString());
+            InitMaterialCos();
+        }
+        else
+        {
+            Debug.LogError(msg);
+        }
+
+    }
+
+    private void CredentialImageCallBack(string msg)
+    {
+        Debug.Log(msg);
+        JObject jObject = JObject.Parse(msg);
+
+        if (jObject["code"].ToString() == "200")
+        {
+            imageSuccessCos = JsonConvert.DeserializeObject<SuccessCOS>(jObject["data"].ToString());
+            InitImageCos();
         }
         else
         {
             Debug.LogError(msg);
         }
 
-    
     }
 
 
@@ -81,18 +158,34 @@ public class COSDownLoad:MonoSingleton<COSDownLoad>
         //transferConfig.DivisionForDownload = 20 * 1024 * 1024;
         // 手动设置高级下载接口的分块大小为 10MB(默认为5MB),不建议此处设置过小的分块值,可能导致频繁重试或下载速度不合预期
         //transferConfig.SliceSizeForDownload = 10 * 1024 * 1024;
+        TransferManager transferManager;  // 初始化 TransferManager
+        String bucket; //存储桶,格式:BucketName-APPID
+        switch (downloadMaterial.type)
+        {
+            case "-1":
+                transferManager = new TransferManager(sceneCosXml, transferConfig);
+                bucket = sceneSuccessCos.bucket;
+                break;
+            case "-2":
+                transferManager = new TransferManager(imageCosXml, transferConfig);
+                bucket = imageSuccessCos.bucket;
+                break;
+
+            default:
+                transferManager = new TransferManager(materialCosXml, transferConfig);
+                bucket = materialSuccessCos.bucket;
+                break;
+        }
 
-
-        // 初始化 TransferManager
-        TransferManager transferManager = new TransferManager(cosXml, transferConfig);
-
-
-        String bucket = successCos.bucket; //存储桶,格式:BucketName-APPID
+      
+    
                                            // String cosPath = "exampleobject"; //对象在存储桶中的位置标识符,即称对象键
                                            // string localDir = System.IO.Path.GetTempPath();//本地文件夹
                                            // string localFileName = "my-local-temp-file"; //指定本地保存的文件名
 
         string localFileName = Path.GetFileName(downloadMaterial.downLoadPath);
+
+        localDir = downloadMaterial.localLoadPath.Substring(0, downloadMaterial.localLoadPath.Length - localFileName.Length);
         // 下载对象
         COSXMLDownloadTask downloadTask = new COSXMLDownloadTask(bucket, downloadMaterial.downLoadPath,
           localDir, localFileName);
@@ -105,6 +198,7 @@ public class COSDownLoad:MonoSingleton<COSDownLoad>
         //};
         Debug.Log(downloadMaterial.downLoadPath);
         downloadTask.onState += OnState;
+        listDownLoadTask.Add(downloadTask);
         try
         {
             COSXML.Transfer.COSXMLDownloadTask.DownloadTaskResult result = await
@@ -124,7 +218,7 @@ public class COSDownLoad:MonoSingleton<COSDownLoad>
             Debug.LogError(downloadMaterial.downLoadPath+ "    CosServerException: " + serverEx.GetInfo());
             DownloadResManager.Instance.DownLoadFaild(downloadTask.localFileName);
         }
-        listDownLoadTask.Add(downloadTask);
+       
     }
 
     private List<COSXML.Transfer.COSXMLDownloadTask.DownloadTaskResult> listResult = new List<COSXMLDownloadTask.DownloadTaskResult>();
@@ -142,10 +236,10 @@ public class COSDownLoad:MonoSingleton<COSDownLoad>
         TransferConfig transferConfig = new TransferConfig();
 
         // 初始化 TransferManager
-        TransferManager transferManager = new TransferManager(cosXml, transferConfig);
+        TransferManager transferManager = new TransferManager(materialCosXml, transferConfig);
 
         // 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.cloud.tencent.com/developer
-        string bucket = successCos.bucket;
+        string bucket = materialSuccessCos.bucket;
         //string localDir = System.IO.Path.GetTempPath();//本地文件夹
         Debug.Log(listDLMaterial.Count);
 
@@ -153,13 +247,14 @@ public class COSDownLoad:MonoSingleton<COSDownLoad>
         {
             string cosPath = listDLMaterial[i].downLoadPath;
             Debug.Log(cosPath);
-            if(cosPath.IsNormalized()||cosPath=="")
+            if(cosPath==null||cosPath=="")
             {
                 DownloadResManager.Instance.DownLoadFaild(listDLMaterial[i].localLoadPath);
                 continue;
             }    
 
             string localFileName = Path.GetFileName(listDLMaterial[i].localLoadPath);
+            Debug.Log(cosPath + "      " + localDir + localFileName);
             COSXMLDownloadTask downloadTask = new COSXMLDownloadTask(bucket, cosPath,
            localDir, localFileName);
             downloadTask.failCallback = delegate (CosClientException clientException, CosServerException serverException)
@@ -195,7 +290,7 @@ public class COSDownLoad:MonoSingleton<COSDownLoad>
 
         try
         {
-            string requestURL =  cosXml.GetObjectUrl(successCos.bucket, downloadMaterial.LocaDataPath);
+            string requestURL =  materialCosXml.GetObjectUrl(materialSuccessCos.bucket, downloadMaterial.LocaDataPath);
             return requestURL;
         }
         catch (COSXML.CosException.CosClientException clientEx)
@@ -213,30 +308,6 @@ public class COSDownLoad:MonoSingleton<COSDownLoad>
 
     }
 
-
-    /// 下载时对单链接限速
-    public async void DownloadObjectTrafficLimit(string cosPath, string localDir, string localFileName)
-    {
-        //.cssg-snippet-body-start:[download-object-traffic-limit]
-        TransferConfig transferConfig = new TransferConfig();
-
-        // 初始化 TransferManager
-        TransferManager transferManager = new TransferManager(cosXml, transferConfig);
-
-        String bucket = successCos.bucket; //存储桶,格式:BucketName-APPID
-       // String cosPath = "exampleobject"; //对象在存储桶中的位置标识符,即称对象键
-       // string localDir = System.IO.Path.GetTempPath();//本地文件夹
-       // string localFileName = "my-local-temp-file"; //指定本地保存的文件名
-
-        GetObjectRequest request = new GetObjectRequest(bucket,
-                cosPath, localDir, localFileName);
-        request.LimitTraffic(8 * 1000 * 1024); // 限制为1MB/s
-
-        COSXMLDownloadTask downloadTask = new COSXMLDownloadTask(request);
-        await transferManager.DownloadAsync(downloadTask);
-        //.cssg-snippet-body-end
-    }
-
     private void OnState(TaskState state)
     {
         Debug.Log(state);

+ 26 - 26
Assets/COSScripts/CustomQCloudCredentialProvider.cs

@@ -1,32 +1,32 @@
-using COSXML.Auth;
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using UnityEngine;
+//using COSXML.Auth;
+//using System;
+//using System.Collections;
+//using System.Collections.Generic;
+//using UnityEngine;
 
-public class CustomQCloudCredentialProvider : DefaultSessionQCloudCredentialProvider
-{
+//public class CustomQCloudCredentialProvider : DefaultSessionQCloudCredentialProvider
+//{
 
-    QCloudCredentialProvider cosCredentialProvider = new CustomQCloudCredentialProvider();
+//    QCloudCredentialProvider cosCredentialProvider = new CustomQCloudCredentialProvider();
 
 
-    // 这里假设开始没有密钥,也可以用初始的临时密钥来初始化
-    public CustomQCloudCredentialProvider() : base(null, null, 0L, null)
-    {
-        ;
-    }
+//    // 这里假设开始没有密钥,也可以用初始的临时密钥来初始化
+//    public CustomQCloudCredentialProvider() : base(null, null, 0L, null)
+//    {
+//        ;
+//    }
 
-    public override void Refresh()
-    {
-        //... 首先通过腾讯云请求临时密钥
-        string tmpSecretId = COSDownLoad.Instance.successCos.credentials.tmpSecretId; //"临时密钥 SecretId", 临时密钥生成和使用指引参见 https://cloud.tencent.com/document/product/436/14048
-        string tmpSecretKey = COSDownLoad.Instance.successCos.credentials.tmpSecretKey; //"临时密钥 SecretKey", 临时密钥生成和使用指引参见 https://cloud.tencent.com/document/product/436/14048
-        string tmpToken = COSDownLoad.Instance.successCos.credentials.sessionToken; //"临时密钥 token", 临时密钥生成和使用指引参见 https://cloud.tencent.com/document/product/436/14048
-        long tmpStartTime = COSDownLoad.Instance.successCos.startTime;//临时密钥有效开始时间,精确到秒
-        long tmpExpiredTime = COSDownLoad.Instance.successCos.expiredTime;//临时密钥有效截止时间,精确到秒
-                                         // 调用接口更新密钥
-        SetQCloudCredential(tmpSecretId, tmpSecretKey,
-          String.Format("{0};{1}", tmpStartTime, tmpExpiredTime), tmpToken);
-    }
-}
+//    public override void Refresh()
+//    {
+//        //... 首先通过腾讯云请求临时密钥
+//        string tmpSecretId = COSDownLoad.Instance.successCos.credentials.tmpSecretId; //"临时密钥 SecretId", 临时密钥生成和使用指引参见 https://cloud.tencent.com/document/product/436/14048
+//        string tmpSecretKey = COSDownLoad.Instance.successCos.credentials.tmpSecretKey; //"临时密钥 SecretKey", 临时密钥生成和使用指引参见 https://cloud.tencent.com/document/product/436/14048
+//        string tmpToken = COSDownLoad.Instance.successCos.credentials.sessionToken; //"临时密钥 token", 临时密钥生成和使用指引参见 https://cloud.tencent.com/document/product/436/14048
+//        long tmpStartTime = COSDownLoad.Instance.successCos.startTime;//临时密钥有效开始时间,精确到秒
+//        long tmpExpiredTime = COSDownLoad.Instance.successCos.expiredTime;//临时密钥有效截止时间,精确到秒
+//                                         // 调用接口更新密钥
+//        SetQCloudCredential(tmpSecretId, tmpSecretKey,
+//          String.Format("{0};{1}", tmpStartTime, tmpExpiredTime), tmpToken);
+//    }
+//}
 

+ 38 - 11
Assets/COSScripts/DownloadResManager.cs

@@ -23,13 +23,17 @@ public class DownloadResManager : MonoSingleton<DownloadResManager>
     /// </summary>
     private List<DownLoadMaterial> listFaildMaterial;
 
+    private Queue<DownLoadMaterial> qDownload;
+    private int maxDownLoad = 1;
+    private int nowDownLoad = 0;
     private string path;
     // Start is called before the first frame update
     void Start()
     {
-        path = Application.persistentDataPath + "/Material";
+        path = Application.persistentDataPath + "/Material/";
         listNotMaterial = new List<DownLoadMaterial>();
         listFaildMaterial = new List<DownLoadMaterial>();
+        qDownload = new Queue<DownLoadMaterial>();
         //先判断是否存在,再创建
         if (!File.Exists(path))
         {
@@ -37,7 +41,7 @@ public class DownloadResManager : MonoSingleton<DownloadResManager>
         }
         else
         {
-            string msg = File.ReadAllText(path+ "/CompletedMaterial.txt");
+            string msg = File.ReadAllText(path + "/CompletedMaterial.txt");
             listCompletedMaterial = JsonConvert.DeserializeObject<List<DownLoadMaterial>>(msg);
         }
         if (listCompletedMaterial == null)
@@ -50,7 +54,7 @@ public class DownloadResManager : MonoSingleton<DownloadResManager>
                 listCompletedMaterial.RemoveAt(i);
             }
         }
-
+        StartCoroutine(DownLoad());
     }
 
     /// <summary>
@@ -65,7 +69,7 @@ public class DownloadResManager : MonoSingleton<DownloadResManager>
             Screen(listDLMaterial[i]);
         }
      //   COSDownLoad cos = new COSDownLoad();
-        COSDownLoad.Instance.TransferBatchDownloadObjects(listNotMaterial, path);
+     //   COSDownLoad.Instance.TransferBatchDownloadObjects(listNotMaterial, path);
 
     }
 
@@ -75,14 +79,16 @@ public class DownloadResManager : MonoSingleton<DownloadResManager>
     /// <param name="downloadMaterial"></param>
     public void DownLoad(DownLoadMaterial downloadMaterial)
     {
+        //Debug.LogError("单个素材下载   " + downloadMaterial.downLoadPath);
+        //List<DownLoadMaterial> list = new List<DownLoadMaterial>();
+        //list.Add(downloadMaterial);
+        // COSDownLoad.Instance.TransferBatchDownloadObjects(list, path);
 
-      
-
-       if( Screen( downloadMaterial) == false)
+        if (Screen(downloadMaterial) == false)
         {
-            List<DownLoadMaterial> list = new List<DownLoadMaterial>();
-            list.Add(downloadMaterial);
-            COSDownLoad.Instance.TransferBatchDownloadObjects(list, path);
+            //List<DownLoadMaterial> list = new List<DownLoadMaterial>();
+            //list.Add(downloadMaterial);
+         //   COSDownLoad.Instance.TransferBatchDownloadObjects(list, path);
         }
         else
         {
@@ -90,6 +96,22 @@ public class DownloadResManager : MonoSingleton<DownloadResManager>
         }
     }
 
+    private IEnumerator DownLoad()
+    {
+      
+
+        while(true)
+        {
+            yield return new WaitForFixedUpdate();
+            if (qDownload.Count>0 && nowDownLoad<maxDownLoad)
+            {
+                nowDownLoad++;
+                COSDownLoad.Instance.TransferDownloadObject(qDownload.Dequeue(), path);
+            }
+        }
+
+    }
+
     /// <summary>
     /// 检测
     /// </summary>
@@ -108,7 +130,11 @@ public class DownloadResManager : MonoSingleton<DownloadResManager>
         }
 
         if (!finish)
+        {
             listNotMaterial.Add(downloadMaterial);
+            qDownload.Enqueue(downloadMaterial);
+        }
+          
 
         return finish;
     }
@@ -119,8 +145,8 @@ public class DownloadResManager : MonoSingleton<DownloadResManager>
     /// <param name="localFilePath"></param>
     public void DownLoadCompleted(string localFilePath)
     {
-       
 
+        nowDownLoad--;
         for (int i = 0; i < listNotMaterial.Count; i++)
         {
             if(Path.GetFileName( listNotMaterial[i].localLoadPath) == localFilePath)
@@ -139,6 +165,7 @@ public class DownloadResManager : MonoSingleton<DownloadResManager>
     /// <param name="localFilePath"></param>
     public void DownLoadFaild(string localFilePath)
     {
+        nowDownLoad--;
         for (int i = 0; i < listNotMaterial.Count; i++)
         {
             if (Path.GetFileName(listNotMaterial[i].localLoadPath) == localFilePath)

+ 16 - 5
Assets/Scripts/LayoutTemplate/TemplateModel.cs

@@ -179,7 +179,7 @@ public class TemplateModel : BaseTemPlate
             data.localLoadPath = Application.persistentDataPath + "/Material/" + Path.GetFileName(value.DownloadPath);
             data.updataTime = GameManager.Instance.m_SceneValue.updateTime;
             data.type = "3";
-
+            MsgHandler.AddListener(value.DownloadPath, HandleMsg);
             DownloadResManager.Instance.DownLoad(data);
             Debug.Log(" SetData " + updateTime);
         }
@@ -206,11 +206,22 @@ public class TemplateModel : BaseTemPlate
             //}
         }
     }
-  
-    //private void HandleMsg(Msg msg)
-    //{
 
-    //}
+    private void HandleMsg(Msg msg)
+    {
+        AssetBundle ab = AssetBundle.LoadFromFile(Data.localSavePath);
+        if (ab == null)
+        {
+            Debug.Log("Failed to load AssetBundle!");
+            return;
+        }
+        var prefab = ab.LoadAsset<GameObject>(ab.LoadAllAssets<GameObject>()[0].name);
+        m_ModelObj = Instantiate(prefab, transform);
+        ab.Unload(false);
+
+        gameObject.AddComponent<ManipulationHandler>();
+        gameObject.AddComponent<BoundingBox>();
+    }
 
     public override void HideCollider()
     {

+ 29 - 5
Assets/Scripts/LayoutTemplate/TemplateVideo.cs

@@ -9,10 +9,10 @@ public class TemplateVideo : BaseTemPlate
     private Navigator.VideoControl m_VideoCtr;
     private AVProVideoPlayer m_Video;
 
-    private string localSavePath;
+    public string localSavePath;
     protected override void OnEnable()
     {
-        localSavePath = Application.persistentDataPath + "/Material/" + Path.GetFileName(Data.downloadPath);
+        //localSavePath = Application.persistentDataPath + "/Material/" + Path.GetFileName(Data.downloadPath);
         base.OnEnable();
         if (GameManager.Instance.IsRuning && string.IsNullOrWhiteSpace(m_Video.GetUrl()))
         {
@@ -60,11 +60,20 @@ public class TemplateVideo : BaseTemPlate
         base.SetData(value, updateTime);
         if (!GameManager.Instance.IsRuning)
         {
-            DownloadManager.Instance.AddDownloadData(Data);
+            localSavePath = Application.persistentDataPath + "/Material/" + Path.GetFileName(value.DownloadPath);
+            // DownloadManager.Instance.AddDownloadData(Data);
+            DownLoadMaterial data = new DownLoadMaterial();
+            data.downLoadPath = value.DownloadPath;
+            data.localLoadPath = Application.persistentDataPath + "/Material/" + Path.GetFileName(value.DownloadPath);
+            data.updataTime = GameManager.Instance.m_SceneValue.updateTime;
+            data.type = "3";
+            MsgHandler.AddListener(value.DownloadPath, HandleMsg);
+            DownloadResManager.Instance.DownLoad(data);
+            Debug.Log(" SetData " + updateTime);
         }
         else
         {
-            localSavePath = Application.persistentDataPath + "/Material/" + Path.GetFileName(Data.downloadPath);
+            localSavePath = Application.persistentDataPath + "/Material/" + Path.GetFileName(value.DownloadPath);
             if (File.Exists(localSavePath))
             {
                 //  m_VideoCtr.VideoURL = Data.localSavePath;
@@ -82,7 +91,7 @@ public class TemplateVideo : BaseTemPlate
     public void SetData(string url)
     {
         Debug.Log(url);
-        localSavePath = Application.persistentDataPath + "/Material/" + Path.GetFileName(Data.downloadPath);
+        localSavePath = Application.persistentDataPath + "/Material/" + Path.GetFileName(url);
         //if(m_VideoCtr ==null)
         //    m_VideoCtr = transform.Find("Screen/Video").GetComponent<Navigator.VideoControl>();
         //m_VideoCtr.VideoURL = url;
@@ -92,6 +101,21 @@ public class TemplateVideo : BaseTemPlate
 
     }
 
+    private void HandleMsg(Msg msg)
+    {
+       
+        if (File.Exists(localSavePath))
+        {
+            //  m_VideoCtr.VideoURL = Data.localSavePath;
+            m_Video.SetUrl(localSavePath);
+        }
+        else
+        {
+            // m_VideoCtr.VideoURL = null;
+            m_Video.SetUrl(null);
+        }
+    }
+
     public override void HideCollider()
     {
         base.HideCollider();

+ 1 - 1
Assets/Scripts/UI/GameManager.cs

@@ -716,7 +716,7 @@ public class GameManager : MonoSingleton<GameManager>
         downLoadMaterial.downLoadPath = MapPicUrl;
         downLoadMaterial.localLoadPath = Application.persistentDataPath + "/Material/" + MapPicUrl;
         downLoadMaterial.updataTime = scene.updateTime;
-        downLoadMaterial.type = "1";
+        downLoadMaterial.type = "-1";
 
         MsgHandler.AddListener(downLoadMaterial.downLoadPath, HandleMsg);
 

+ 5 - 3
Assets/Scripts/UI/LoginPanel.cs

@@ -92,7 +92,7 @@ public class LoginPanel : BaseUI
 
         //m_SNBtn.onClick.AddListener(OnClickSnBtn);
 
-        // OnClickLogin();
+         OnClickLogin();
     }
 
     #region UI监听事件
@@ -261,9 +261,10 @@ public class LoginPanel : BaseUI
     {
 
 #if UNITY_EDITOR
-        m_AccountStr = "1768147286@qq.com";
+        // m_AccountStr = "1768147286@qq.com";
         //m_AccountStr = "666666@qq.com";
         //m_PasswordStr = "ghztech@402B";
+        m_AccountStr = "jiajun.hu@ghz-tech.com";
 #endif
         if (string.IsNullOrWhiteSpace(m_AccountStr))
         {
@@ -598,7 +599,7 @@ public class LoginPanel : BaseUI
                 string filename = Path.GetFileName(mat.icon);
                 data1.downLoadPath = mat.icon;
                 data1.updataTime = mat.updateTime;
-
+                data1.type = "1";
                 data1.localLoadPath = Application.persistentDataPath + "/Materail/" + filename;
                 listMaterail.Add(data1);
             }
@@ -614,6 +615,7 @@ public class LoginPanel : BaseUI
                         data1.downLoadPath = matObj.DownloadPath;
                         data1.updataTime = mat.updateTime;
                         data1.localLoadPath = Application.persistentDataPath + "/Materail/" + filename;
+                        data1.type = "1";
                         listMaterail.Add(data1);
                     }
                 }

+ 0 - 1
Packages/manifest.json

@@ -18,7 +18,6 @@
     "com.unity.xr.interactionsubsystems": "1.0.1",
     "com.unity.xr.openxr": "1.5.3",
     "jh.baseeditor.engine": "https://gogs.ghz-tech.com:8843/GHzGlass/GHZBasePackage.git",
-    "jh.immersalsdk.engine": "https://gogs.ghz-tech.com:8843/GHzGlass/ImmersalSDK.git#ImmersalSDK_Nreal",
     "jh.trilib.engine": "https://gogs.ghz-tech.com:8843/GHzGlass/TriLibXR.git",
     "jh.xr.engine": "https://gogs.ghz-tech.com:8843/GHzGlass/GHZSDKXR.git#XRSDK_Nreal",
     "com.unity.modules.ai": "1.0.0",

+ 0 - 11
Packages/packages-lock.json

@@ -267,17 +267,6 @@
       },
       "hash": "78e593f6e911cf4aafbc031005e7f2cdc76136e8"
     },
-    "jh.immersalsdk.engine": {
-      "version": "https://gogs.ghz-tech.com:8843/GHzGlass/ImmersalSDK.git#ImmersalSDK_Nreal",
-      "depth": 0,
-      "source": "git",
-      "dependencies": {
-        "com.unity.xr.management": "4.0.1",
-        "com.unity.xr.legacyinputhelpers": "2.1.2",
-        "com.unity.inputsystem": "1.4.2"
-      },
-      "hash": "5e1c7fa684c24381b6cee3ca2bf90f5eb1e45d06"
-    },
     "jh.trilib.engine": {
       "version": "https://gogs.ghz-tech.com:8843/GHzGlass/TriLibXR.git",
       "depth": 0,