Browse Source

替换下载

DGJ 1 year ago
parent
commit
bfbdc1b503

+ 3 - 1
Assets/Scripts/Download/DownloadManager.cs

@@ -1,4 +1,4 @@
-using LitJson;
+using LitJson;
 using Newtonsoft.Json;
 using SC.XR.Unity;
 using System;
@@ -329,6 +329,8 @@ public class DownloadManager : SingletonMono<DownloadManager>
         }));
     }
 
+  //  private void ImageHandleMsg()
+
     /// <summary>
     /// 获取图片
     /// </summary>

+ 25 - 2
Assets/Scripts/LayoutTemplate/TemplateImage.cs

@@ -29,7 +29,15 @@ public class TemplateImage : BaseTemPlate
         base.OnEnable();
         if (GameManager.Instance.IsRuning && m_Image.sprite == null && Data != null)
         {
-            DownloadManager.Instance.GetImage(Data, m_Image);
+         //   DownloadManager.Instance.GetImage(Data, m_Image);
+
+            DownLoadMaterial data = new DownLoadMaterial();
+            data.downLoadPath = Data.downloadPath;
+            data.localLoadPath = Application.persistentDataPath + "/Material/" + Path.GetFileName(Data.downloadPath);
+            data.updataTime = GameManager.Instance.m_SceneValue.updateTime;
+            data.type = "1";
+            MsgHandler.AddListener(data.downLoadPath, HandleMsg);
+            DownloadResManager.Instance.DownLoad(data);
         }
     }
 
@@ -49,10 +57,25 @@ public class TemplateImage : BaseTemPlate
         }
         else
         {
-            DownloadManager.Instance.GetImage(Data, m_Image);
+            // DownloadManager.Instance.GetImage(Data, m_Image);
+            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 = "1";
+            MsgHandler.AddListener(data.downLoadPath, HandleMsg);
+            DownloadResManager.Instance.DownLoad(data);
         }
     }
 
+    private void HandleMsg(Msg msg)
+    {
+        Texture2D texture = new Texture2D(1, 1);
+        texture.LoadImage((byte[])msg.Value);
+        Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.one * 0.5f);
+        m_Image.sprite = sprite;
+    }
+
     public void SetLocaImageData(MaterialObjValue value)
     {
         m_Image.sprite = ResMgr.Instance.Load<Sprite>(value.DownloadPath);

+ 15 - 1
Assets/Scripts/LayoutTemplate/TemplateModel.cs

@@ -171,7 +171,16 @@ public class TemplateModel : BaseTemPlate
         //下载列表中加入数据
         if (!GameManager.Instance.IsRuning)
         {
-            DownloadManager.Instance.AddDownloadData(Data);
+         //   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";
+
+            DownloadResManager.Instance.DownLoad(data);
             Debug.Log(" SetData " + updateTime);
         }
         else
@@ -198,6 +207,11 @@ public class TemplateModel : BaseTemPlate
         }
     }
   
+    //private void HandleMsg(Msg msg)
+    //{
+
+    //}
+
     public override void HideCollider()
     {
         base.HideCollider();

+ 2 - 2
ProjectSettings/ProjectSettings.asset

@@ -924,6 +924,7 @@ PlayerSettings:
   metroSplashScreenUseBackgroundColor: 1
   platformCapabilities:
     WindowsStoreApps:
+      EnterpriseAuthentication: False
       OfflineMapsManagement: False
       HumanInterfaceDevice: False
       Location: False
@@ -936,7 +937,6 @@ PlayerSettings:
       InternetClientServer: False
       VideosLibrary: False
       Objects3D: False
-      InternetClient: True
       RemoteSystem: False
       BlockedChatMessages: False
       PhoneCall: False
@@ -958,9 +958,9 @@ PlayerSettings:
       RecordedCallsFolder: False
       Contacts: False
       Proximity: False
+      InternetClient: True
       CodeGeneration: False
       BackgroundMediaPlayback: False
-      EnterpriseAuthentication: False
   metroTargetDeviceFamilies:
     Desktop: False
     Holographic: False