#region www download assetbundle resources///<summary>///www download assetbundle resources///</summary> <param name= "url" ></param>///<returns></returns> public static bool UW
Wwload (string url) {try {var assetbundlename = GetFileName (URL);
Directory string path = Assetbundleloger.applicationpersistentassets + Assetbundleloger.getpathgap ();
String FilePath = path + assetbundlename +. zip; No directory generates an if (!
Directory.Exists (path)) directory.createdirectory (path);
Directory if there is no download if (file.exists (path + Assetbundlename + ". Assetbundle")) {
return true;
www www = new www (URL);
stopwatch SW = new Stopwatch (); Sw.
Start ();
byte[] ty = new byte[0]; while (!www.isdone) {if (sw).
Elapsedmilliseconds >= 1000) {if (Www.error!= null)
{MessageBoxWnd.Instance.Show ("Connection Timeout-----please later"); Sw.
Stop ();
return false; else {if (sw.
Elapsedmilliseconds >= 4500) {ty = www.bytes; if (Ty. Length = = 0) {MessageBoxWnd.Instance.Show ("Connection Timeout-----
Please later, no return data "); Sw.
Stop ();
return false; (}}}}} TRy {System.IO.File.WriteAllBytes (FilePath, www.bytes);
catch (Exception e) {MessageBoxWnd.Instance.Show (e.message);
Throw
//Extract file Decompress (FilePath, path); Sw.
Stop (); Debug.Log (SW.
Elapsedmilliseconds);
System.IO.File.Delete (FilePath);
catch (Exception e) {MessageBoxWnd.Instance.Show (e.message);
Throw
return true; #endregion///<summary>///remove name///</summary>///<param name=
' Path ' ></param>///<returns></returns> public static string GetFileName (string path) {var Urlarray = path.
Split ('/'); var urlarrayc = Urlarray[urlarRay.
LENGTH-1]; var name = Urlarrayc.
Split ('. ');
return name[0]; #region Extract Files///<summary>///Extract Files///</summary>///<param Name= "Gzipfile" > Zip package file name </param>///<param name= "TargetPath" > Decompression target path </param> PU
Blic static void Decompress (string gzipfile, String TargetPath) {string directoryname = TargetPath; if (! Directory.Exists (directoryname)) directory.createdirectory (directoryname);//Generate decompression directory string currentdirectory = d
Irectoryname;
byte[] data = new BYTE[1];
int size = 0;
ZipEntry theentry = null; using (zipinputstream s = new Zipinputstream (File.openread (gzipfile))) {while (Theentry = S.
Getnextentry ())!= null) {if (theentry.isdirectory) {//The node is a directory If(!
Directory.Exists (CurrentDirectory + theentry.name)) directory.createdirectory (CurrentDirectory + theEntry.Name);
} else {if (theentry.name!= String.Empty) {//check if the multilevel directory exists if (theEntry.Name.Contains "//") {string parentdirpath = TheEntry.Name.Remove (theentry).
Name.lastindexof ("//") + 1); if (! Directory.Exists (Parentdirpath)) {Directory.createdir
Ectory (CurrentDirectory + parentdirpath); }//Unzip the file to the specified directory using (FileStream str Eamwriter = file.create (CurrentDirectory + theentry.name)) {W Hile(true)
{data = new byte[theentry.compressedsize]; Size = s.read (data, 0, data.)
Length);
if (size <= 0) break;
StreamWriter.Write (data, 0, size);
} streamwriter.close ();
}}} s.close (); }} #endregion