Răsfoiți Sursa

资源下载,本地文件md5在下载时计算

tanghai 7 ani în urmă
părinte
comite
303656bdf0

+ 20 - 12
Unity/Assets/Editor/BuildEditor/BuildEditor.cs

@@ -20,6 +20,12 @@ namespace ETEditor
 		IOS,
 		PC,
 	}
+	
+	public enum BuildType
+	{
+		Development,
+		Release,
+	}
 
 	public class BuildEditor : EditorWindow
 	{
@@ -28,6 +34,7 @@ namespace ETEditor
 		private PlatformType platformType;
 		private bool isBuildExe;
 		private bool isContainAB;
+		private BuildType buildType;
 		private BuildOptions buildOptions = BuildOptions.AllowDebugging | BuildOptions.Development;
 		private BuildAssetBundleOptions buildAssetBundleOptions = BuildAssetBundleOptions.None;
 
@@ -39,21 +46,22 @@ namespace ETEditor
 
 		private void OnGUI()
 		{
-			if (GUILayout.Button("标记"))
-			{
-				SetPackingTagAndAssetBundle();
-			}
-
-			if (GUILayout.Button("清除标记"))
-			{
-				ClearPackingTagAndAssetBundle();
-			}
-
 			this.platformType = (PlatformType)EditorGUILayout.EnumPopup(platformType);
 			this.isBuildExe = EditorGUILayout.Toggle("是否打包EXE: ", this.isBuildExe);
 			this.isContainAB = EditorGUILayout.Toggle("是否同将资源打进EXE: ", this.isContainAB);
-			this.buildOptions = (BuildOptions)EditorGUILayout.EnumMaskField("BuildOptions(可多选): ", this.buildOptions);
-			this.buildAssetBundleOptions = (BuildAssetBundleOptions)EditorGUILayout.EnumMaskField("BuildAssetBundleOptions(可多选): ", this.buildAssetBundleOptions);
+			this.buildType = (BuildType)EditorGUILayout.EnumPopup("BuildType: ", this.buildType);
+			
+			switch (buildType)
+			{
+				case BuildType.Development:
+					this.buildOptions = BuildOptions.Development | BuildOptions.AutoRunPlayer | BuildOptions.ConnectWithProfiler | BuildOptions.AllowDebugging;
+					break;
+				case BuildType.Release:
+					this.buildOptions = BuildOptions.None;
+					break;
+			}
+			
+			this.buildAssetBundleOptions = (BuildAssetBundleOptions)EditorGUILayout.EnumFlagsField("BuildAssetBundleOptions(可多选): ", this.buildAssetBundleOptions);
 
 			if (GUILayout.Button("开始打包"))
 			{

+ 1 - 1
Unity/Assets/Editor/BuildEditor/BuildHelper.cs

@@ -10,7 +10,7 @@ namespace ETEditor
 
 		public static string BuildFolder = "../Release/{0}/StreamingAssets/";
 		
-		[MenuItem("Tools/编译Hotfix")]
+		//[MenuItem("Tools/编译Hotfix")]
 		public static void BuildHotfix()
 		{
 			System.Diagnostics.Process process = new System.Diagnostics.Process();

+ 1 - 0
Unity/Assets/Res/Config/BuffConfig.txt.meta

@@ -3,6 +3,7 @@ guid: 0f3540faabf2b7e4c83e81cb7ba6a096
 timeCreated: 1505113794
 licenseType: Free
 TextScriptImporter:
+  externalObjects: {}
   userData: 
   assetBundleName: config.unity3d
   assetBundleVariant: 

+ 1 - 0
Unity/Assets/Res/Config/UnitConfig.txt.meta

@@ -3,6 +3,7 @@ guid: c245c7dda13b3ad43b2278925e922899
 timeCreated: 1505441234
 licenseType: Free
 TextScriptImporter:
+  externalObjects: {}
   userData: 
   assetBundleName: config.unity3d
   assetBundleVariant: 

+ 6 - 2
Unity/Assets/Res/Unit/Skeleton/Texture/Skeleton_D.tif.meta

@@ -4,6 +4,7 @@ timeCreated: 1510979420
 licenseType: Free
 TextureImporter:
   fileIDToRecycleName: {}
+  externalObjects: {}
   serializedVersion: 4
   mipmaps:
     mipMapMode: 0
@@ -44,8 +45,9 @@ TextureImporter:
   spriteMeshType: 1
   alignment: 0
   spritePivot: {x: 0.5, y: 0.5}
-  spriteBorder: {x: 0, y: 0, z: 0, w: 0}
   spritePixelsToUnits: 100
+  spriteBorder: {x: 0, y: 0, z: 0, w: 0}
+  spriteGenerateFallbackPhysicsShape: 1
   alphaUsage: 1
   alphaIsTransparency: 0
   spriteTessellationDetail: -1
@@ -57,18 +59,20 @@ TextureImporter:
   platformSettings:
   - buildTarget: DefaultTexturePlatform
     maxTextureSize: 1024
+    resizeAlgorithm: 0
     textureFormat: -1
     textureCompression: 1
     compressionQuality: 50
     crunchedCompression: 0
     allowsAlphaSplitting: 0
     overridden: 0
+    androidETC2FallbackOverride: 0
   spriteSheet:
     serializedVersion: 2
     sprites: []
     outline: []
     physicsShape: []
-  spritePackingTag: Unit
+  spritePackingTag: 
   userData: 
   assetBundleName: 
   assetBundleVariant: 

+ 1 - 1
Unity/Assets/Scripts/Entity/UnityWebRequestAsync.cs

@@ -88,7 +88,7 @@ namespace ETModel
 			
 			url = url.Replace(" ", "%20");
 			this.Request = UnityWebRequest.Get(url);
-			this.Request.Send();
+			this.Request.SendWebRequest();
 			
 			return this.tcs.Task;
 		}

+ 24 - 7
Unity/Assets/Scripts/Helper/BundleHelper.cs

@@ -1,4 +1,5 @@
 using System;
+using System.IO;
 using System.Threading.Tasks;
 using UnityEngine;
 
@@ -7,13 +8,6 @@ namespace ETModel
 	public static class BundleHelper
 	{
 		public static async Task DownloadBundle()
-		{
-			Game.EventSystem.Run(EventIdType.LoadingBegin);
-			await StartDownLoadResources();
-			Game.EventSystem.Run(EventIdType.LoadingFinish);
-		}
-		
-		public static async Task StartDownLoadResources()
 		{
 			if (Define.IsAsync)
 			{
@@ -22,7 +16,14 @@ namespace ETModel
 					using (BundleDownloaderComponent bundleDownloaderComponent = Game.Scene.AddComponent<BundleDownloaderComponent>())
 					{
 						await bundleDownloaderComponent.StartAsync();
+						
+						Game.EventSystem.Run(EventIdType.LoadingBegin);
+						
+						await bundleDownloaderComponent.DownloadAsync();
 					}
+					
+					Game.EventSystem.Run(EventIdType.LoadingFinish);
+					
 					Game.Scene.GetComponent<ResourcesComponent>().LoadOneBundle("StreamingAssets");
 					ResourcesComponent.AssetBundleManifestObject = (AssetBundleManifest)Game.Scene.GetComponent<ResourcesComponent>().GetAsset("StreamingAssets", "AssetBundleManifest");
 				}
@@ -33,5 +34,21 @@ namespace ETModel
 
 			}
 		}
+
+		public static string GetBundleMD5(VersionConfig streamingVersionConfig, string bundleName)
+		{
+			string path = Path.Combine(PathHelper.AppHotfixResPath, bundleName);
+			if (File.Exists(path))
+			{
+				return MD5Helper.FileMD5(path);
+			}
+			
+			if (streamingVersionConfig.FileInfoDict.ContainsKey(bundleName))
+			{
+				return streamingVersionConfig.FileInfoDict[bundleName].MD5;	
+			}
+
+			return "";
+		}
 	}
 }

+ 66 - 101
Unity/Assets/Scripts/Module/AssetsBundle/BundleDownloaderComponent.cs

@@ -21,8 +21,8 @@ namespace ETModel
 	/// </summary>
 	public class BundleDownloaderComponent : Component
 	{
-		public VersionConfig VersionConfig { get; private set; }
-
+		private VersionConfig remoteVersionConfig;
+		
 		public Queue<string> bundles;
 
 		public long TotalSize;
@@ -33,81 +33,100 @@ namespace ETModel
 
 		public UnityWebRequestAsync webRequest;
 
-		public TaskCompletionSource<bool> Tcs;
-
 		public async Task StartAsync()
 		{
-			using (UnityWebRequestAsync webRequestAsync = ComponentFactory.Create<UnityWebRequestAsync>())
+			// 获取远程的Version.txt
+			string versionUrl = "";
+			try
 			{
-				string versionUrl = GlobalConfigComponent.Instance.GlobalProto.GetUrl() + "StreamingAssets/" + "Version.txt";
-				//Log.Debug(versionUrl);
-				await webRequestAsync.DownloadAsync(versionUrl);
-				this.VersionConfig = JsonHelper.FromJson<VersionConfig>(webRequestAsync.Request.downloadHandler.text);
-				//Log.Debug(JsonHelper.ToJson(this.VersionConfig));
-			}
+				using (UnityWebRequestAsync webRequestAsync = ComponentFactory.Create<UnityWebRequestAsync>())
+				{
+					versionUrl = GlobalConfigComponent.Instance.GlobalProto.GetUrl() + "StreamingAssets/" + "Version.txt";
+					//Log.Debug(versionUrl);
+					await webRequestAsync.DownloadAsync(versionUrl);
+					remoteVersionConfig = JsonHelper.FromJson<VersionConfig>(webRequestAsync.Request.downloadHandler.text);
+					//Log.Debug(JsonHelper.ToJson(this.VersionConfig));
+				}
 
+			}
+			catch (Exception e)
+			{
+				throw new Exception($"url: {versionUrl}");
+			}
 
-			VersionConfig localVersionConfig;
-			// 对比本地的Version.txt
-			string versionPath = Path.Combine(PathHelper.AppHotfixResPath, "Version.txt");
-			if (File.Exists(versionPath))
+			// 获取streaming目录的Version.txt
+			VersionConfig streamingVersionConfig;
+			string versionPath = Path.Combine(PathHelper.AppResPath4Web, "Version.txt");
+			using (UnityWebRequestAsync request = ComponentFactory.Create<UnityWebRequestAsync>())
 			{
-				localVersionConfig = JsonHelper.FromJson<VersionConfig>(File.ReadAllText(versionPath));
+				await request.DownloadAsync(versionPath);
+				streamingVersionConfig = JsonHelper.FromJson<VersionConfig>(request.Request.downloadHandler.text);
 			}
-			else
+			
+			// 删掉远程不存在的文件
+			DirectoryInfo directoryInfo = new DirectoryInfo(PathHelper.AppHotfixResPath);
+			if (directoryInfo.Exists)
 			{
-				versionPath = Path.Combine(PathHelper.AppResPath4Web, "Version.txt");
-				using (UnityWebRequestAsync request = ComponentFactory.Create<UnityWebRequestAsync>())
+				FileInfo[] fileInfos = directoryInfo.GetFiles();
+				foreach (FileInfo fileInfo in fileInfos)
 				{
-					await request.DownloadAsync(versionPath);
-					localVersionConfig = JsonHelper.FromJson<VersionConfig>(request.Request.downloadHandler.text);
+					if (remoteVersionConfig.FileInfoDict.ContainsKey(fileInfo.Name))
+					{
+						continue;
+					}
+					
+					fileInfo.Delete();
 				}
 			}
+			else
+			{
+				directoryInfo.Create();
+			}
 
-
-			// 先删除服务器端没有的ab
-			foreach (FileVersionInfo fileVersionInfo in localVersionConfig.FileInfoDict.Values)
+			// 对比MD5
+			foreach (FileVersionInfo fileVersionInfo in remoteVersionConfig.FileInfoDict.Values)
 			{
-				if (this.VersionConfig.FileInfoDict.ContainsKey(fileVersionInfo.File))
+				// 对比md5
+				string localFileMD5 = BundleHelper.GetBundleMD5(streamingVersionConfig, fileVersionInfo.File);
+				if (fileVersionInfo.MD5 == localFileMD5)
 				{
 					continue;
 				}
-				string abPath = Path.Combine(PathHelper.AppHotfixResPath, fileVersionInfo.File);
-				File.Delete(abPath);
+				this.bundles.Enqueue(fileVersionInfo.File);
+				this.TotalSize += fileVersionInfo.Size;
 			}
+		}
 
-			// 再下载
-			foreach (FileVersionInfo fileVersionInfo in this.VersionConfig.FileInfoDict.Values)
+		public int Progress
+		{
+			get
 			{
-				FileVersionInfo localVersionInfo;
-				if (localVersionConfig.FileInfoDict.TryGetValue(fileVersionInfo.File, out localVersionInfo))
+				if (this.TotalSize == 0)
 				{
-					if (fileVersionInfo.MD5 == localVersionInfo.MD5)
-					{
-						continue;
-					}
+					return 0;
 				}
 
-				if (fileVersionInfo.File == "Version.txt")
+				long alreadyDownloadBytes = 0;
+				foreach (string downloadedBundle in this.downloadedBundles)
 				{
-					continue;
+					long size = this.remoteVersionConfig.FileInfoDict[downloadedBundle].Size;
+					alreadyDownloadBytes += size;
 				}
-
-				this.bundles.Enqueue(fileVersionInfo.File);
-				this.TotalSize += fileVersionInfo.Size;
+				if (this.webRequest != null)
+				{
+					alreadyDownloadBytes += (long)this.webRequest.Request.downloadedBytes;
+				}
+				return (int)(alreadyDownloadBytes * 100f / this.TotalSize);
 			}
+		}
 
-			if (this.bundles.Count == 0)
+		public async Task DownloadAsync()
+		{
+			if (this.bundles.Count == 0 && this.downloadingBundle == "")
 			{
 				return;
 			}
 
-			//Log.Debug($"need download bundles: {this.bundles.ToList().ListToString()}");
-			await this.WaitAsync();
-		}
-
-		private async void UpdateAsync()
-		{
 			try
 			{
 				while (true)
@@ -129,10 +148,6 @@ namespace ETModel
 								byte[] data = this.webRequest.Request.downloadHandler.data;
 
 								string path = Path.Combine(PathHelper.AppHotfixResPath, this.downloadingBundle);
-								if (!Directory.Exists(Path.GetDirectoryName(path)))
-								{
-									Directory.CreateDirectory(Path.GetDirectoryName(path));
-								}
 								using (FileStream fs = new FileStream(path, FileMode.Create))
 								{
 									fs.Write(data, 0, data.Length);
@@ -151,61 +166,11 @@ namespace ETModel
 					this.downloadingBundle = "";
 					this.webRequest = null;
 				}
-
-				using (FileStream fs = new FileStream(Path.Combine(PathHelper.AppHotfixResPath, "Version.txt"), FileMode.Create))
-				using (StreamWriter sw = new StreamWriter(fs))
-				{
-					sw.Write(JsonHelper.ToJson(this.VersionConfig));
-				}
-
-				this.Tcs?.SetResult(true);
 			}
 			catch (Exception e)
 			{
 				Log.Error(e);
 			}
 		}
-
-		public int Progress
-		{
-			get
-			{
-				if (this.VersionConfig == null)
-				{
-					return 0;
-				}
-
-				if (this.TotalSize == 0)
-				{
-					return 0;
-				}
-
-				long alreadyDownloadBytes = 0;
-				foreach (string downloadedBundle in this.downloadedBundles)
-				{
-					long size = this.VersionConfig.FileInfoDict[downloadedBundle].Size;
-					alreadyDownloadBytes += size;
-				}
-				if (this.webRequest != null)
-				{
-					alreadyDownloadBytes += (long)this.webRequest.Request.downloadedBytes;
-				}
-				return (int)(alreadyDownloadBytes * 100f / this.TotalSize);
-			}
-		}
-
-		private Task<bool> WaitAsync()
-		{
-			if (this.bundles.Count == 0 && this.downloadingBundle == "")
-			{
-				return Task.FromResult(true);
-			}
-
-			this.Tcs = new TaskCompletionSource<bool>();
-
-			UpdateAsync();
-
-			return this.Tcs.Task;
-		}
 	}
 }

+ 1 - 1
Unity/Assets/StreamingAssets/Version.txt

@@ -1 +1 @@
-{"Version":0,"TotalSize":0,"FileInfoDict":{}}
+{"Version":0,"TotalSize":0,"FileInfoDict":{"code.unity3d":{"File":"code.unity3d","MD5":"717b465e058569de3338bd35e3b61010","Size":53153},"config.unity3d":{"File":"config.unity3d","MD5":"a12f131715c3317791fadca3d5a09501","Size":1832},"StreamingAssets":{"File":"StreamingAssets","MD5":"e5088c233f6a4d00e219c532113ab8e1","Size":1100},"uilobby.unity3d":{"File":"uilobby.unity3d","MD5":"2bbc2e612dc5a3a75ced90889bf599e4","Size":6983},"uilogin.unity3d":{"File":"uilogin.unity3d","MD5":"adceeab2dff8ef77e7cf1a936f5b7f19","Size":7716},"unit.unity3d":{"File":"unit.unity3d","MD5":"88f3ced17e15a52a8da806a53cf60300","Size":563234},"Version.txt":{"File":"Version.txt","MD5":"ce8f31db907b74aee34a2c53d25c3e64","Size":710}}}

+ 2 - 1
Unity/Assets/StreamingAssets/Version.txt.meta

@@ -1,8 +1,9 @@
 fileFormatVersion: 2
 guid: d0629e7fcea294e479c86a7b5fe33268
-timeCreated: 1525428885
+timeCreated: 1531539482
 licenseType: Pro
 DefaultImporter:
+  externalObjects: {}
   userData: 
   assetBundleName: 
   assetBundleVariant: 

+ 5 - 2
Unity/Assets/ThirdParty/ILRuntime/Generated/CLRBindings.cs

@@ -78,10 +78,14 @@ namespace ILRuntime.Runtime.Generated
             ETModel_SessionCallbackComponent_Binding.Register(app);
             System_Collections_Generic_Dictionary_2_Int32_Action_1_ILTypeInstance_Binding.Register(app);
             ETModel_Component_Binding.Register(app);
-            ETModel_ProtobufHelper_Binding.Register(app);
+            ETModel_Packet_Binding.Register(app);
+            ETModel_NetworkComponent_Binding.Register(app);
+            ETModel_IMessagePacker_Binding.Register(app);
             ETModel_MessageInfo_Binding.Register(app);
+            ETModel_ProtobufHelper_Binding.Register(app);
             System_Threading_Tasks_TaskCompletionSource_1_ILTypeInstance_Binding.Register(app);
             System_Threading_CancellationToken_Binding.Register(app);
+            ETModel_ErrorCode_Binding.Register(app);
             ETModel_RpcException_Binding.Register(app);
             System_Collections_Generic_Dictionary_2_UInt16_List_1_ILTypeInstance_Binding.Register(app);
             ETModel_OpcodeTypeComponent_Binding.Register(app);
@@ -113,7 +117,6 @@ namespace ILRuntime.Runtime.Generated
             ETModel_GlobalProto_Binding.Register(app);
             ETModel_NetworkHelper_Binding.Register(app);
             UnityEngine_UI_InputField_Binding.Register(app);
-            ETModel_NetworkComponent_Binding.Register(app);
             ETModel_ComponentFactory_Binding.Register(app);
 
             ILRuntime.CLR.TypeSystem.CLRType __clrType = null;

+ 52 - 0
Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_ErrorCode_Binding.cs

@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+using ILRuntime.CLR.TypeSystem;
+using ILRuntime.CLR.Method;
+using ILRuntime.Runtime.Enviorment;
+using ILRuntime.Runtime.Intepreter;
+using ILRuntime.Runtime.Stack;
+using ILRuntime.Reflection;
+using ILRuntime.CLR.Utils;
+
+namespace ILRuntime.Runtime.Generated
+{
+    unsafe class ETModel_ErrorCode_Binding
+    {
+        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
+        {
+            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
+            MethodBase method;
+            Type[] args;
+            Type type = typeof(ETModel.ErrorCode);
+            args = new Type[]{typeof(System.Int32)};
+            method = type.GetMethod("IsRpcNeedThrowException", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, IsRpcNeedThrowException_0);
+
+
+        }
+
+
+        static StackObject* IsRpcNeedThrowException_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 1);
+
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            System.Int32 @error = ptr_of_this_method->Value;
+
+
+            var result_of_this_method = ETModel.ErrorCode.IsRpcNeedThrowException(@error);
+
+            __ret->ObjectType = ObjectTypes.Integer;
+            __ret->Value = result_of_this_method ? 1 : 0;
+            return __ret + 1;
+        }
+
+
+
+    }
+}

+ 13 - 0
Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_ErrorCode_Binding.cs.meta

@@ -0,0 +1,13 @@
+fileFormatVersion: 2
+guid: d510e2c93f9dce344a52263562341270
+timeCreated: 1531218034
+licenseType: Pro
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 63 - 0
Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_IMessagePacker_Binding.cs

@@ -0,0 +1,63 @@
+using System;
+using System.Collections.Generic;
+using System.Reflection;
+using System.Runtime.InteropServices;
+
+using ILRuntime.CLR.TypeSystem;
+using ILRuntime.CLR.Method;
+using ILRuntime.Runtime.Enviorment;
+using ILRuntime.Runtime.Intepreter;
+using ILRuntime.Runtime.Stack;
+using ILRuntime.Reflection;
+using ILRuntime.CLR.Utils;
+
+namespace ILRuntime.Runtime.Generated
+{
+    unsafe class ETModel_IMessagePacker_Binding
+    {
+        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
+        {
+            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
+            MethodBase method;
+            Type[] args;
+            Type type = typeof(ETModel.IMessagePacker);
+            args = new Type[]{typeof(System.Type), typeof(System.IO.Stream)};
+            method = type.GetMethod("DeserializeFrom", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, DeserializeFrom_0);
+
+
+        }
+
+
+        static StackObject* DeserializeFrom_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 3);
+
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            System.IO.Stream @stream = (System.IO.Stream)typeof(System.IO.Stream).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
+            System.Type @type = (System.Type)typeof(System.Type).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
+            ETModel.IMessagePacker instance_of_this_method = (ETModel.IMessagePacker)typeof(ETModel.IMessagePacker).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+
+            var result_of_this_method = instance_of_this_method.DeserializeFrom(@type, @stream);
+
+            object obj_result_of_this_method = result_of_this_method;
+            if(obj_result_of_this_method is CrossBindingAdaptorType)
+            {    
+                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance, true);
+            }
+            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method, true);
+        }
+
+
+
+    }
+}

+ 13 - 0
Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_IMessagePacker_Binding.cs.meta

@@ -0,0 +1,13 @@
+fileFormatVersion: 2
+guid: fd9ee5572f10e254b847627429546f7c
+timeCreated: 1531218034
+licenseType: Pro
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 25 - 2
Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_NetworkComponent_Binding.cs

@@ -21,15 +21,38 @@ namespace ILRuntime.Runtime.Generated
             MethodBase method;
             Type[] args;
             Type type = typeof(ETModel.NetworkComponent);
+            args = new Type[]{};
+            method = type.GetMethod("get_MessagePacker", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, get_MessagePacker_0);
             args = new Type[]{typeof(System.Net.IPEndPoint)};
             method = type.GetMethod("Create", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, Create_0);
+            app.RegisterCLRMethodRedirection(method, Create_1);
 
 
         }
 
 
-        static StackObject* Create_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        static StackObject* get_MessagePacker_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 1);
+
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            ETModel.NetworkComponent instance_of_this_method = (ETModel.NetworkComponent)typeof(ETModel.NetworkComponent).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+
+            var result_of_this_method = instance_of_this_method.MessagePacker;
+
+            object obj_result_of_this_method = result_of_this_method;
+            if(obj_result_of_this_method is CrossBindingAdaptorType)
+            {    
+                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance);
+            }
+            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
+        }
+
+        static StackObject* Create_1(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
         {
             ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
             StackObject* ptr_of_this_method;

+ 75 - 0
Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_Packet_Binding.cs

@@ -15,6 +15,81 @@ namespace ILRuntime.Runtime.Generated
 {
     unsafe class ETModel_Packet_Binding
     {
+        public static void Register(ILRuntime.Runtime.Enviorment.AppDomain app)
+        {
+            BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
+            MethodBase method;
+            Type[] args;
+            Type type = typeof(ETModel.Packet);
+            args = new Type[]{};
+            method = type.GetMethod("get_Opcode", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, get_Opcode_0);
+            args = new Type[]{};
+            method = type.GetMethod("get_Flag", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, get_Flag_1);
+            args = new Type[]{};
+            method = type.GetMethod("get_Stream", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, get_Stream_2);
+
+
+        }
+
+
+        static StackObject* get_Opcode_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 1);
+
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            ETModel.Packet instance_of_this_method = (ETModel.Packet)typeof(ETModel.Packet).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+
+            var result_of_this_method = instance_of_this_method.Opcode;
+
+            __ret->ObjectType = ObjectTypes.Integer;
+            __ret->Value = result_of_this_method;
+            return __ret + 1;
+        }
+
+        static StackObject* get_Flag_1(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 1);
+
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            ETModel.Packet instance_of_this_method = (ETModel.Packet)typeof(ETModel.Packet).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+
+            var result_of_this_method = instance_of_this_method.Flag;
+
+            __ret->ObjectType = ObjectTypes.Integer;
+            __ret->Value = result_of_this_method;
+            return __ret + 1;
+        }
+
+        static StackObject* get_Stream_2(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 1);
+
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            ETModel.Packet instance_of_this_method = (ETModel.Packet)typeof(ETModel.Packet).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+
+            var result_of_this_method = instance_of_this_method.Stream;
+
+            object obj_result_of_this_method = result_of_this_method;
+            if(obj_result_of_this_method is CrossBindingAdaptorType)
+            {    
+                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance);
+            }
+            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
+        }
+
+
 
     }
 }

+ 2 - 36
Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_ProtobufHelper_Binding.cs

@@ -21,49 +21,15 @@ namespace ILRuntime.Runtime.Generated
             MethodBase method;
             Type[] args;
             Type type = typeof(ETModel.ProtobufHelper);
-            args = new Type[]{typeof(System.Type), typeof(System.Byte[]), typeof(System.Int32), typeof(System.Int32)};
-            method = type.GetMethod("FromBytes", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, FromBytes_0);
             args = new Type[]{typeof(System.Object)};
             method = type.GetMethod("ToBytes", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, ToBytes_1);
+            app.RegisterCLRMethodRedirection(method, ToBytes_0);
 
 
         }
 
 
-        static StackObject* FromBytes_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
-        {
-            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
-            StackObject* ptr_of_this_method;
-            StackObject* __ret = ILIntepreter.Minus(__esp, 4);
-
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
-            System.Int32 @length = ptr_of_this_method->Value;
-
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
-            System.Int32 @index = ptr_of_this_method->Value;
-
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 3);
-            System.Byte[] @bytes = (System.Byte[])typeof(System.Byte[]).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-            __intp.Free(ptr_of_this_method);
-
-            ptr_of_this_method = ILIntepreter.Minus(__esp, 4);
-            System.Type @type = (System.Type)typeof(System.Type).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
-            __intp.Free(ptr_of_this_method);
-
-
-            var result_of_this_method = ETModel.ProtobufHelper.FromBytes(@type, @bytes, @index, @length);
-
-            object obj_result_of_this_method = result_of_this_method;
-            if(obj_result_of_this_method is CrossBindingAdaptorType)
-            {    
-                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance, true);
-            }
-            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method, true);
-        }
-
-        static StackObject* ToBytes_1(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        static StackObject* ToBytes_0(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
         {
             ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
             StackObject* ptr_of_this_method;

+ 41 - 4
Unity/Assets/ThirdParty/ILRuntime/Generated/ETModel_Session_Binding.cs

@@ -19,17 +19,25 @@ namespace ILRuntime.Runtime.Generated
         {
             BindingFlags flag = BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly;
             MethodBase method;
+            FieldInfo field;
             Type[] args;
             Type type = typeof(ETModel.Session);
             args = new Type[]{typeof(ETModel.IMessage)};
             method = type.GetMethod("Send", flag, null, args, null);
             app.RegisterCLRMethodRedirection(method, Send_0);
+            args = new Type[]{};
+            method = type.GetMethod("get_Network", flag, null, args, null);
+            app.RegisterCLRMethodRedirection(method, get_Network_1);
             args = new Type[]{typeof(System.Byte), typeof(System.UInt16), typeof(System.Byte[])};
             method = type.GetMethod("Send", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, Send_1);
+            app.RegisterCLRMethodRedirection(method, Send_2);
             args = new Type[]{typeof(ETModel.IRequest)};
             method = type.GetMethod("Call", flag, null, args, null);
-            app.RegisterCLRMethodRedirection(method, Call_2);
+            app.RegisterCLRMethodRedirection(method, Call_3);
+
+            field = type.GetField("Error", flag);
+            app.RegisterCLRFieldGetter(field, get_Error_0);
+            app.RegisterCLRFieldSetter(field, set_Error_0);
 
 
         }
@@ -54,7 +62,27 @@ namespace ILRuntime.Runtime.Generated
             return __ret;
         }
 
-        static StackObject* Send_1(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        static StackObject* get_Network_1(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        {
+            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
+            StackObject* ptr_of_this_method;
+            StackObject* __ret = ILIntepreter.Minus(__esp, 1);
+
+            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
+            ETModel.Session instance_of_this_method = (ETModel.Session)typeof(ETModel.Session).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
+            __intp.Free(ptr_of_this_method);
+
+            var result_of_this_method = instance_of_this_method.Network;
+
+            object obj_result_of_this_method = result_of_this_method;
+            if(obj_result_of_this_method is CrossBindingAdaptorType)
+            {    
+                return ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance);
+            }
+            return ILIntepreter.PushObject(__ret, __mStack, result_of_this_method);
+        }
+
+        static StackObject* Send_2(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
         {
             ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
             StackObject* ptr_of_this_method;
@@ -79,7 +107,7 @@ namespace ILRuntime.Runtime.Generated
             return __ret;
         }
 
-        static StackObject* Call_2(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
+        static StackObject* Call_3(ILIntepreter __intp, StackObject* __esp, IList<object> __mStack, CLRMethod __method, bool isNewObj)
         {
             ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
             StackObject* ptr_of_this_method;
@@ -104,6 +132,15 @@ namespace ILRuntime.Runtime.Generated
         }
 
 
+        static object get_Error_0(ref object o)
+        {
+            return ((ETModel.Session)o).Error;
+        }
+        static void set_Error_0(ref object o, object v)
+        {
+            ((ETModel.Session)o).Error = (System.Int32)v;
+        }
+
 
     }
 }

+ 1 - 0
Unity/ProjectSettings/GraphicsSettings.asset

@@ -36,6 +36,7 @@ GraphicsSettings:
   - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0}
   - {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0}
   - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
+  - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
   m_PreloadedShaders: []
   m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
     type: 0}