|
@@ -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);
|
|
|
+
|
|
|
+
|
|
|
+ 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);
|
|
|
+
|
|
|
+ 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);
|