Commit aa0acd55 authored by JiangWanZhi's avatar JiangWanZhi

解压文件出来的地方改个位置

parent a0171998
...@@ -523,22 +523,25 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler ...@@ -523,22 +523,25 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
if (utilsTools.IsWin == true) if (utilsTools.IsWin == true)
zpath = zpath.Replace("/", "\\"); zpath = zpath.Replace("/", "\\");
gameScenUser.createWorkDirectory(); gameScenUser.createWorkDirectory();
string outPath = GameScenUserInfo.getAllRoot(); string outPath = Application.persistentDataPath + $"/Test_MyPic/{gameScenUser.id}";//GameScenUserInfo.getAllRoot(); //这里记得后面Test_MyPic改成MyPic
if(utilsTools.IsWin == true)
if (!Directory.Exists(outPath)) //没有这个路径说明是第一次下载解压的
{
Directory.CreateDirectory(outPath);
if (utilsTools.IsWin == true)
{ {
outPath = outPath.Replace("/", "\\"); outPath = outPath.Replace("/", "\\");
} }
if (utilsTools.IsExistIO(gameScenUser.getColorImgLocalPath()) == false)
{
utilsTools.setGDataByKey("beginUnZip", utilsTools.getTotalMillisecond()); utilsTools.setGDataByKey("beginUnZip", utilsTools.getTotalMillisecond());
ZipUtility.UnzipFile(zpath, outPath, "tuse" + gameScenUser.id); ZipUtility.UnzipFile(zpath, outPath, "tuse" + gameScenUser.id);
utilsTools.setGDataByKey("endUnZip", utilsTools.getTotalMillisecond()); utilsTools.setGDataByKey("endUnZip", utilsTools.getTotalMillisecond());
} }
utilsTools.setGDataByKey(EventName.DataName.Data_nowSelectUseData, gameScenUser); utilsTools.setGDataByKey(EventName.DataName.Data_nowSelectUseData, gameScenUser);
string lineImg = gameScenUser.getLineImgLocalPath();
utilsTools.setGDataByKey("downGaoQing", utilsTools.getTotalMillisecond());
EventDispatcher.Dispatch(EventName.Event.Event_LoadingChange, 0.3f); //解压完成,或者原先本地就有了,开始加载本地文件,这儿给个0.3f
gameShowView.GetComponent<mainGameView>().loadGameImgId(); gameShowView.GetComponent<mainGameView>().loadGameImgId();
} }
...@@ -592,11 +595,14 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler ...@@ -592,11 +595,14 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
{ {
if (isOk) if (isOk)
{ {
utilsTools.addTimer_Update(gameObject, "unZipNext", (String _) =>{ //utilsTools.addTimer_Update(gameObject, "unZipNext", (String _) =>{
utilsTools.setGDataByKey("downZipEnd", utilsTools.getTotalMillisecond()); // utilsTools.setGDataByKey("downZipEnd", utilsTools.getTotalMillisecond());
// onZipFileHandler(gameScenUser);
// return false;
//});
EventDispatcher.Dispatch(EventName.Event.Event_LoadingChange, 0.2f); //下载完成,这儿给个0.2f
onZipFileHandler(gameScenUser); onZipFileHandler(gameScenUser);
return false;
});
} }
})); }));
} }
...@@ -608,12 +614,9 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler ...@@ -608,12 +614,9 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
} }
IEnumerator LoadAndBytesUnzipWithWeb(string url, string exportPath,NotifyBoolParam back) IEnumerator LoadAndBytesUnzipWithWeb(string url, string exportPath,NotifyBoolParam back)
{ {
Debug.Log("exportPath : " + exportPath);
using (UnityWebRequest uwr = UnityWebRequest.Get(url)) using (UnityWebRequest uwr = UnityWebRequest.Get(url))
{ {
EventDispatcher.Dispatch(EventName.Event.Event_LoadingChange,0.2f); //开始下载,进度条这儿给个0.1
yield return uwr.SendWebRequest(); yield return uwr.SendWebRequest();
if (uwr.isHttpError == true || uwr.isNetworkError == true) if (uwr.isHttpError == true || uwr.isNetworkError == true)
{ {
...@@ -625,9 +628,6 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler ...@@ -625,9 +628,6 @@ public class gameSceneLogic : MonoBehaviour, IEventHandler
var data = uwr.downloadHandler.data; var data = uwr.downloadHandler.data;
File.WriteAllBytes(exportPath, data); File.WriteAllBytes(exportPath, data);
back(true); back(true);
// 酌情使用即可
//File.Delete(zipPath);
//Directory.Delete(exportPath, true);
} }
} }
} }
......
...@@ -7,7 +7,6 @@ using UnityEngine.UI; ...@@ -7,7 +7,6 @@ using UnityEngine.UI;
using System.Linq; using System.Linq;
using DG.Tweening; using DG.Tweening;
using TMPro; using TMPro;
using UnityEditor.ShaderGraph;
public class GroupListManager : MonoBehaviour public class GroupListManager : MonoBehaviour
{ {
......
...@@ -777,7 +777,6 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法 ...@@ -777,7 +777,6 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
} }
public virtual bool loadGameImgId(GameScenUserInfo gameUserInfo) public virtual bool loadGameImgId(GameScenUserInfo gameUserInfo)
{ {
Debug.Log($"11111 加载图片{gameUserInfo.id}");
string linePath = gameUserInfo.getLineImgLocalPath(); string linePath = gameUserInfo.getLineImgLocalPath();
string colorPath = gameUserInfo.getColorImgLocalPath(); string colorPath = gameUserInfo.getColorImgLocalPath();
string jsonPath = gameUserInfo.getJsonLocalPath(); string jsonPath = gameUserInfo.getJsonLocalPath();
...@@ -801,29 +800,21 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法 ...@@ -801,29 +800,21 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
utilsTools.setGDataByKey("loadBinBegin", utilsTools.getTotalMillisecond()); utilsTools.setGDataByKey("loadBinBegin", utilsTools.getTotalMillisecond());
TaskManages.getInstance().insertTask(this, (System.Object[] _) => TaskManages.getInstance().insertTask(this, (System.Object[] _) =>
{ {
string binpath = colorPath.Substring(0, linePath.Length - 4) + ".bin"; //string binpath = colorPath.Substring(0, linePath.Length - 4) + ".bin";
if (utilsTools.IsWin == true) //if (utilsTools.IsWin == true)
{ //{
binpath = binpath.Replace("/", "\\"); // binpath = binpath.Replace("/", "\\");
} //}
Byte[] bytes = System.IO.File.ReadAllBytes(binpath); //Byte[] bytes = System.IO.File.ReadAllBytes(binpath);
bytesInitDigitMatrix(bytes); //bytesInitDigitMatrix(bytes);
Debug.Log("bin初始化完成--------------"); Debug.Log("bin初始化完成--------------");
}); });
//utilsTools.setGDataByKey("loadBinEnd", utilsTools.getTotalMillisecond()); //utilsTools.setGDataByKey("loadBinEnd", utilsTools.getTotalMillisecond());
//utilsTools.setGDataByKey("downJson", utilsTools.getTotalMillisecond()); //utilsTools.setGDataByKey("downJson", utilsTools.getTotalMillisecond());
EventDispatcher.Dispatch(EventName.Event.Event_LoadingChange); //开始加载本地文件
string dicpath = Application.persistentDataPath + $"/MyPic/{gameUserInfo.id}"; string dicpath = Application.persistentDataPath + $"/MyPic/{gameUserInfo.id}";
CurPicName = gameUserInfo.id; CurPicName = gameUserInfo.id;
Debug.Log($"11111 本地位置{dicpath}");
if (!Directory.Exists(dicpath))
{
Directory.CreateDirectory(dicpath);
}
EventDispatcher.Dispatch(EventName.Event.Event_LoadingChange);
//loadFileInfo(gameUserInfo.json, jsonPath, 3, gameUserInfo.id); //loadFileInfo(gameUserInfo.json, jsonPath, 3, gameUserInfo.id);
////utilsTools.setGDataByKey("loadGaoQing", utilsTools.getTotalMillisecond()); ////utilsTools.setGDataByKey("loadGaoQing", utilsTools.getTotalMillisecond());
...@@ -1769,7 +1760,6 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法 ...@@ -1769,7 +1760,6 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
public void StartGame() public void StartGame()
{ {
Debug.Log("11111 StartGame");
GameMgr obj = Resources.Load<GameMgr>("perfabs/GameMgr"); GameMgr obj = Resources.Load<GameMgr>("perfabs/GameMgr");
GameMgr item = Instantiate<GameMgr>(obj); GameMgr item = Instantiate<GameMgr>(obj);
...@@ -1778,7 +1768,6 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法 ...@@ -1778,7 +1768,6 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
item.transform.localRotation = Quaternion.Euler(0, 0, 0); item.transform.localRotation = Quaternion.Euler(0, 0, 0);
item.transform.localScale= Vector3.one; item.transform.localScale= Vector3.one;
EventDispatcher.Dispatch(EventName.Event.Event_LoadingChange); //开始初始化
string path = Application.persistentDataPath + $"/MyPic/{CurPicName}/"; string path = Application.persistentDataPath + $"/MyPic/{CurPicName}/";
StartCoroutine(LoadPic(path, $"{CurPicName}", item)); StartCoroutine(LoadPic(path, $"{CurPicName}", item));
...@@ -1786,14 +1775,13 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法 ...@@ -1786,14 +1775,13 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
IEnumerator LoadPic(string dirpath,string name, GameMgr item) IEnumerator LoadPic(string dirpath,string name, GameMgr item)
{ {
Texture2D png=null; Texture2D png = null;
Sprite jpg=null; Sprite jpg = null;
Texture2D jpg_texture = null; Texture2D jpg_texture = null;
string pngpath = dirpath+$"{name}_png.png"; string pngpath = dirpath+$"{name}_png.png";
string jpgpath = dirpath + $"{name}_jpg.jpg"; string jpgpath = dirpath + $"{name}_jpg.jpg";
string loadpath = ""; string loadpath = "";
Debug.Log($"11111 金加载图片");
bool localflag = false; bool localflag = false;
if (File.Exists(pngpath)) //有保存过图片 if (File.Exists(pngpath)) //有保存过图片
{ {
...@@ -1813,7 +1801,10 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法 ...@@ -1813,7 +1801,10 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
} }
else else
{ {
png = Resources.Load<Texture2D>("cc2D9Z2w9k0evqUiCQ/png"); string path = Application.streamingAssetsPath + "/cc2D9Z2w9k0evqUiCQ/cc2D9Z2w9k0evqUiCQ_png.png";
WWW www = new WWW(path);
yield return www;
png = www.texture;
} }
...@@ -1835,87 +1826,57 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法 ...@@ -1835,87 +1826,57 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
} }
else else
{ {
jpg_texture = Resources.Load<Texture2D>("cc2D9Z2w9k0evqUiCQ/jpg"); string path = Application.streamingAssetsPath + "/cc2D9Z2w9k0evqUiCQ/cc2D9Z2w9k0evqUiCQ_jpg.jpg";
WWW www = new WWW(path);
//jpg = Sprite.Create(jpg_texture, new Rect(0, 0, jpg_texture.width, jpg_texture.height), new Vector2(0.5f, 0.5f)); yield return www;
jpg_texture = www.texture;
} }
string binlocalpath = Application.persistentDataPath + $"/MyPic/{name}/{name}_json.bin"; string binlocalpath = Application.persistentDataPath + $"/MyPic/{name}/{name}_json.bin";
Debug.Log($"11111 不在 {binlocalpath}");
ResJsonData jsondata = null; ResJsonData jsondata = null;
if (!File.Exists(binlocalpath)) if (!File.Exists(binlocalpath))
{ {
Debug.Log($"11111 0000");
string path = Application.streamingAssetsPath + "/cc2D9Z2w9k0evqUiCQ/cc2D9Z2w9k0evqUiCQ_json.bin"; string path = Application.streamingAssetsPath + "/cc2D9Z2w9k0evqUiCQ/cc2D9Z2w9k0evqUiCQ_json.bin";
Debug.Log($"11111 -----");
//#if UNITY_ANDROID
// path = "file://" + path;
//#endif
WWW www = new WWW(path); WWW www = new WWW(path);
Debug.Log($"11111 {path}");
while (!www.isDone) while (!www.isDone)
{ {
} }
Debug.Log($"11111 222");
MemoryStream stream = new MemoryStream(www.bytes); MemoryStream stream = new MemoryStream(www.bytes);
//二进制反序列化 //二进制反序列化
Debug.Log($"11111 3333");
BinaryFormatter bf = new BinaryFormatter(); BinaryFormatter bf = new BinaryFormatter();
Debug.Log($"11111 444");
jsondata = (ResJsonData)bf.Deserialize(stream); jsondata = (ResJsonData)bf.Deserialize(stream);
Debug.Log($"11111 555 {jsondata.allPos.Count}");
} }
else else
{ {
Debug.Log($"11111 在");
jsondata = getdata("cc2D9Z2w9k0evqUiCQ"); jsondata = getdata("cc2D9Z2w9k0evqUiCQ");
} }
string bindynamiclocalpath = Application.persistentDataPath + $"/MyPic/{name}/{name}_dynamic.bin"; string bindynamiclocalpath = Application.persistentDataPath + $"/MyPic/{name}/{name}_dynamic.bin";
Debug.Log($"11111 不在 {binlocalpath}");
DynamicData dynamic = null; DynamicData dynamic = null;
if (!File.Exists(bindynamiclocalpath)) if (!File.Exists(bindynamiclocalpath))
{ {
Debug.Log($"11111 0000");
string path = Application.streamingAssetsPath + "/cc2D9Z2w9k0evqUiCQ/cc2D9Z2w9k0evqUiCQ_dynamic.bin"; string path = Application.streamingAssetsPath + "/cc2D9Z2w9k0evqUiCQ/cc2D9Z2w9k0evqUiCQ_dynamic.bin";
Debug.Log($"11111 -----");
//#if UNITY_ANDROID
// path = "file://" + path;
//#endif
WWW www = new WWW(path); WWW www = new WWW(path);
Debug.Log($"11111 {path}");
while (!www.isDone) while (!www.isDone)
{ {
} }
Debug.Log($"11111 222");
MemoryStream stream = new MemoryStream(www.bytes); MemoryStream stream = new MemoryStream(www.bytes);
//二进制反序列化 //二进制反序列化
Debug.Log($"11111 3333");
BinaryFormatter bf = new BinaryFormatter(); BinaryFormatter bf = new BinaryFormatter();
Debug.Log($"11111 444");
dynamic = (DynamicData)bf.Deserialize(stream); dynamic = (DynamicData)bf.Deserialize(stream);
Debug.Log($"11111 555 {dynamic.step.Count}");
} }
else else
{ {
Debug.Log($"11111 在");
dynamic = getdynamicdata("cc2D9Z2w9k0evqUiCQ"); dynamic = getdynamicdata("cc2D9Z2w9k0evqUiCQ");
} }
if (localflag) //加载本地的到这里就回去了,下面是第一次 if (localflag) //加载本地的到这里就回去了,下面是加载工程;里面的后续跑的
{ {
Debug.Log($"111111 11初始化");
item.Init("cc2D9Z2w9k0evqUiCQ", png, jpg, jsondata, dynamic); item.Init("cc2D9Z2w9k0evqUiCQ", png, jpg, jsondata, dynamic);
yield break; yield break;
} }
Debug.Log($"11111 开始保存");
SaveManager.Instance.SaveRes("cc2D9Z2w9k0evqUiCQ", dynamic, png); SaveManager.Instance.SaveRes("cc2D9Z2w9k0evqUiCQ", dynamic, png);
SaveManager.Instance.SaveJPG("cc2D9Z2w9k0evqUiCQ", jpg_texture); SaveManager.Instance.SaveJPG("cc2D9Z2w9k0evqUiCQ", jpg_texture);
SaveManager.Instance.SaveJson("cc2D9Z2w9k0evqUiCQ", jsondata); SaveManager.Instance.SaveJson("cc2D9Z2w9k0evqUiCQ", jsondata);
...@@ -1924,15 +1885,9 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法 ...@@ -1924,15 +1885,9 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
{ {
yield return null; yield return null;
} }
Debug.Log($"11111 保存完成");
//UnityWebRequest request = UnityWebRequestTexture.GetTexture(pngpath);
//yield return request.SendWebRequest();
//Debug.Log($"11111 Png图 {pngpath} done {request.isDone} error{request.error}");
//if (request.isDone)
//{
// png = DownloadHandlerTexture.GetContent(request);
//}
//加载本地的
loadpath = pngpath; loadpath = pngpath;
#if UNITY_ANDROID #if UNITY_ANDROID
loadpath = "file://" + pngpath; loadpath = "file://" + pngpath;
...@@ -1955,19 +1910,7 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法 ...@@ -1955,19 +1910,7 @@ public class mainGameView : MonoBehaviour //大图的处理、具体的玩法
jpg_texture = www_jpg.texture; jpg_texture = www_jpg.texture;
jpg = Sprite.Create(jpg_texture, new Rect(0, 0, jpg_texture.width, jpg_texture.height), new Vector2(0.5f, 0.5f)); jpg = Sprite.Create(jpg_texture, new Rect(0, 0, jpg_texture.width, jpg_texture.height), new Vector2(0.5f, 0.5f));
} }
//request = UnityWebRequestTexture.GetTexture(jpgpath);
//yield return request.SendWebRequest();
//Debug.Log($"11111 jpg图 {jpgpath} done {request.isDone} error{request.error}");
//if (request.isDone)
//{
// jpg_texture = DownloadHandlerTexture.GetContent(request);
// jpg = Sprite.Create(jpg_texture, new Rect(0, 0, jpg_texture.width, jpg_texture.height), new Vector2(0.5f, 0.5f));
//}
jsondata = getdata("cc2D9Z2w9k0evqUiCQ"); jsondata = getdata("cc2D9Z2w9k0evqUiCQ");
Debug.Log($"11111 开始初始化{jsondata.allPos.Count}");
item.Init("cc2D9Z2w9k0evqUiCQ", png, jpg, jsondata, dynamic); item.Init("cc2D9Z2w9k0evqUiCQ", png, jpg, jsondata, dynamic);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment