فهرست منبع

增加非泛型Call方法

tanghai 8 سال پیش
والد
کامیت
c9e3815b19

+ 1 - 1
Config/StartConfig/LocalAllServer.txt

@@ -1 +1 @@
-{ "_t" : "StartConfig", "_id" : NumberLong("98547768819754"), "components" : [{ "_t" : "OuterConfig", "Host" : "127.0.0.1", "Port" : 10002, "Host2" : null }, { "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20000 }, { "_t" : "HttpConfig", "Url" : "", "AppId" : 0, "AppKey" : "", "ManagerSystemUrl" : "" }, { "_t" : "DBConfig", "ConnectionString" : null, "DBName" : null }], "AppId" : 1, "AppType" : "AllServer", "ServerIP" : "*" }
+{ "_t" : "StartConfig", "_id" : NumberLong("98547768819754"), "components" : [{ "_t" : "OuterConfig", "Host" : "172.16.20.27", "Port" : 10002, "Host2" : null }, { "_t" : "InnerConfig", "Host" : "127.0.0.1", "Port" : 20000 }, { "_t" : "HttpConfig", "Url" : "", "AppId" : 0, "AppKey" : "", "ManagerSystemUrl" : "" }, { "_t" : "DBConfig", "ConnectionString" : null, "DBName" : null }], "AppId" : 1, "AppType" : "AllServer", "ServerIP" : "*" }

+ 1 - 2
Tools/cwRsync/Config/exclude.txt

@@ -1,6 +1,5 @@
 .git/
 Logs/
-Tools/
 Bin/
 Server/packages/
 Temp/
@@ -8,4 +7,4 @@ Server/Server.sdf
 Unity/Library/
 Unity/Temp/
 */obj
-Unity/
+IOS-Build

+ 1 - 1
Tools/cwRsync/Config/rsyncConfig.txt

@@ -1 +1 @@
-{ "_t" : "RsyncConfig", "Host" : "172.16.20.30", "Account" : "tanghai", "Password" : "1234567890", "RelativePath" : "Source/Egametang", "Exclude" : [".git/", "Logs/", "Tools/", "Bin/", "Server/packages/", "Temp/", "Server/Server.sdf", "Unity/Library/", "Unity/Temp/", "*/obj", "Unity/"] }
+{ "_t" : "RsyncConfig", "Host" : "172.16.20.48", "Account" : "mac", "Password" : "1234567890", "RelativePath" : "Source/Egametang", "Exclude" : [".git/", "Logs/", "Bin/", "Server/packages/", "Temp/", "Server/Server.sdf", "Unity/Library/", "Unity/Temp/", "*/obj", "IOS-Build"] }

+ 5 - 4
Tools/cwRsync/Config/rsyncd.conf

@@ -1,12 +1,13 @@
-uid = root
-gid = root
+uid = 0
+gid = 0
 use chroot = no
 max connections = 100
 read only = no
 write only = no
 log file =/var/log/rsyncd.log
+fake super = yes
 [Upload]
-path = /home/tanghai/
-auth users = tanghai
+path = /home/mac/
+auth users = mac
 secrets file = /etc/rsyncd.secrets
 list = yes

+ 1 - 1
Tools/cwRsync/Config/rsyncd.secrets

@@ -1 +1 @@
-tanghai:1234567890
+mac:1234567890

+ 39 - 0
Unity/Assets/Editor/BuildEditor/BuildIOSEditor.cs

@@ -0,0 +1,39 @@
+#if UNITY_IOS
+using System.IO;
+using UnityEditor;
+using UnityEditor.Callbacks;
+using UnityEditor.iOS.Xcode;
+
+namespace MyEditor
+{
+	public class BuildIOSEditor : EditorWindow
+	{
+		[PostProcessBuild]
+		private static void OnPostprocessBuild(BuildTarget target, string pathToBuildProject)
+		{
+			AssetDatabase.Refresh(ImportAssetOptions.ForceUpdate);
+			string _projPath = PBXProject.GetPBXProjectPath(pathToBuildProject);
+			PBXProject project = new PBXProject();
+			project.ReadFromString(File.ReadAllText(_projPath));
+			string targetGuid = project.TargetGuidByName("Unity-iPhone");
+
+			//project.AddFrameworkToProject(targetGuid, "Security.framework", false);
+
+			project.WriteToFile(_projPath);
+
+
+			// plist
+			string plistPath = pathToBuildProject + "/Info.plist";
+			PlistDocument plist = new PlistDocument();
+			plist.ReadFromString(File.ReadAllText(plistPath));
+			PlistElementDict rootDict = plist.root;
+			
+			PlistElementDict dictTmp = rootDict.CreateDict("NSAppTransportSecurity");
+			dictTmp.SetBoolean("NSAllowsArbitraryLoads", true);
+
+			// 保存plist  
+			plist.WriteToFile(plistPath);
+		}
+	}
+}
+#endif

+ 11 - 0
Unity/Assets/Editor/BuildEditor/BuildIOSEditor.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 2d9e797a78884f0b87db09a7423425fc
+timeCreated: 1510919356
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 1 - 1
Unity/Assets/Res/Config/GlobalProto.txt

@@ -1 +1 @@
-{ "_t" : "GlobalProto", "AssetBundleServerUrl" : "http://127.0.0.1:8080/", "Address" : "127.0.0.1:10002" }
+{ "_t" : "GlobalProto", "AssetBundleServerUrl" : "http://172.16.20.27:8080/", "Address" : "172.16.20.27:10002" }

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

@@ -1,6 +1,7 @@
 fileFormatVersion: 2
 guid: 943f3c476130c4f4f8ae55ef3ccd38ba
-timeCreated: 18446744011573954816
+timeCreated: 1510969659
+licenseType: Free
 TextureImporter:
   fileIDToRecycleName: {}
   serializedVersion: 4
@@ -67,7 +68,7 @@ TextureImporter:
     sprites: []
     outline: []
     physicsShape: []
-  spritePackingTag: 
+  spritePackingTag: Unit
   userData: 
   assetBundleName: 
   assetBundleVariant: 

+ 1 - 1
Unity/Assets/Scripts/Base/Config/ConfigHelper.cs

@@ -9,7 +9,7 @@ namespace Model
 		{
 			try
 			{
-				GameObject config = Game.Scene.GetComponent<ResourcesComponent>().GetAsset<GameObject>("config", "Config");
+				GameObject config = Game.Scene.GetComponent<ResourcesComponent>().GetAsset<GameObject>("config.unity3d", "Config");
 				string configStr = config.Get<TextAsset>(key).text;
 				return configStr;
 			}

+ 1 - 1
Unity/Assets/Scripts/Component/ResourcesComponent.cs

@@ -66,7 +66,7 @@ namespace Model
 
 		public K GetAsset<K>(string bundleName, string prefab) where K : class
 		{
-			string path = $"{bundleName}.unity3d/{prefab}".ToLower();
+			string path = $"{bundleName}/{prefab}".ToLower();
 
 			UnityEngine.Object resource = null;
 			if (!this.resourceCache.TryGetValue(path, out resource))

+ 65 - 0
Unity/Assets/Scripts/Entity/Session.cs

@@ -134,6 +134,71 @@ namespace Model
 
 			this.network.MessageDispatcher.Dispatch(this, op, offset, messageBytes, (AMessage)message);
 		}
+		
+		/// <summary>
+		/// Rpc调用,发送一个消息,等待返回一个消息
+		/// </summary>
+		public Task<AResponse> Call(ARequest request)
+		{
+			request.RpcId = ++RpcId;
+			this.SendMessage(request);
+
+			var tcs = new TaskCompletionSource<AResponse>();
+			this.requestCallback[RpcId] = (message) =>
+			{
+				try
+				{
+					AResponse response = (AResponse)message;
+					if (response.Error > 100)
+					{
+						tcs.SetException(new RpcException(response.Error, response.Message));
+						return;
+					}
+					//Log.Debug($"recv: {MongoHelper.ToJson(response)}");
+					tcs.SetResult(response);
+				}
+				catch (Exception e)
+				{
+					tcs.SetException(new Exception($"Rpc Error: {message.GetType().FullName}", e));
+				}
+			};
+
+			return tcs.Task;
+		}
+		
+		/// <summary>
+		/// Rpc调用
+		/// </summary>
+		public Task<AResponse> Call(ARequest request, CancellationToken cancellationToken)
+		{
+			request.RpcId = ++RpcId;
+			this.SendMessage(request);
+
+			var tcs = new TaskCompletionSource<AResponse>();
+
+			this.requestCallback[RpcId] = (message) =>
+			{
+				try
+				{
+					AResponse response = (AResponse)message;
+					if (response.Error > 100)
+					{
+						tcs.SetException(new RpcException(response.Error, response.Message));
+						return;
+					}
+					//Log.Debug($"recv: {MongoHelper.ToJson(response)}");
+					tcs.SetResult(response);
+				}
+				catch (Exception e)
+				{
+					tcs.SetException(new Exception($"Rpc Error: {request.GetType().FullName}", e));
+				}
+			};
+
+			cancellationToken.Register(() => { this.requestCallback.Remove(RpcId); });
+
+			return tcs.Task;
+		}
 
 		/// <summary>
 		/// Rpc调用

+ 1 - 1
Unity/Assets/Scripts/Factory/UnitFactory.cs

@@ -7,7 +7,7 @@ namespace Model
         public static Unit Create(long id)
         {
 	        ResourcesComponent resourcesComponent = Game.Scene.GetComponent<ResourcesComponent>();
-	        GameObject bundleGameObject = resourcesComponent.GetAsset<GameObject>("Unit", "Unit");
+	        GameObject bundleGameObject = resourcesComponent.GetAsset<GameObject>("Unit.unity3d", "Unit");
 	        GameObject prefab = bundleGameObject.Get<GameObject>("Skeleton");
 	        
             UnitComponent unitComponent = Game.Scene.GetComponent<UnitComponent>();

+ 23 - 12
Unity/Assets/Scripts/Helper/BundleHelper.cs

@@ -20,26 +20,37 @@ namespace Model
 		{
 			if (Define.IsAsync)
 			{
-				string url = GlobalConfigComponent.Instance.GlobalProto.GetUrl() + "StreamingAssets/StreamingAssets";
+				//string url = GlobalConfigComponent.Instance.GlobalProto.GetUrl() + "StreamingAssets/StreamingAssets";
+				//try
+				//{
+				//	using (WWWAsync wwwAsync = EntityFactory.Create<WWWAsync>())
+				//	{
+				//		await wwwAsync.DownloadAsync(url);
+				//		ResourcesComponent.AssetBundleManifestObject = wwwAsync.www.assetBundle.LoadAsset<AssetBundleManifest>("AssetBundleManifest");
+				//		wwwAsync.www.assetBundle.Unload(false);
+				//	}
+				//}
+				//catch (Exception e)
+				//{
+				//	Log.Error($"下载错误: {url} {e}");
+				//	return;
+				//}
 				try
 				{
-					using (WWWAsync wwwAsync = EntityFactory.Create<WWWAsync>())
+					using (BundleDownloaderComponent bundleDownloaderComponent = Game.Scene.AddComponent<BundleDownloaderComponent>())
 					{
-						await wwwAsync.DownloadAsync(url);
-						ResourcesComponent.AssetBundleManifestObject = wwwAsync.www.assetBundle.LoadAsset<AssetBundleManifest>("AssetBundleManifest");
-						wwwAsync.www.assetBundle.Unload(false);
+						await bundleDownloaderComponent.StartAsync();
 					}
+					Log.Debug("11111111111111111111111111111111");
+					Game.Scene.GetComponent<ResourcesComponent>().LoadOneBundle("StreamingAssets");
+					ResourcesComponent.AssetBundleManifestObject = Game.Scene.GetComponent<ResourcesComponent>().GetAsset<AssetBundleManifest>("StreamingAssets", "AssetBundleManifest");
+					Log.Debug("111111111111111111111111111111112");
 				}
 				catch (Exception e)
 				{
-					Log.Error($"下载错误: {url} {e}");
-					return;
-				}
-				
-				using (BundleDownloaderComponent bundleDownloaderComponent = Game.Scene.AddComponent<BundleDownloaderComponent>())
-				{
-					await bundleDownloaderComponent.StartAsync();
+					Log.Error(e.ToString());
 				}
+
 			}
 		}
 	}

+ 2 - 2
Unity/Assets/Scripts/Helper/DllHelper.cs

@@ -14,7 +14,7 @@ namespace Model
 #if ILRuntime
 		public static void LoadHotfixAssembly()
 		{
-			GameObject code = Game.Scene.GetComponent<ResourcesComponent>().GetAsset<GameObject>("code", "Code");
+			GameObject code = Game.Scene.GetComponent<ResourcesComponent>().GetAsset<GameObject>("code.unity3d", "Code");
 			byte[] assBytes = code.Get<TextAsset>("Hotfix.dll").bytes;
 			byte[] mdbBytes = code.Get<TextAsset>("Hotfix.pdb").bytes;
 
@@ -27,7 +27,7 @@ namespace Model
 #else
 		public static Assembly LoadHotfixAssembly()
 		{
-			GameObject code = Game.Scene.GetComponent<ResourcesComponent>().GetAsset<GameObject>("code", "Code");
+			GameObject code = Game.Scene.GetComponent<ResourcesComponent>().GetAsset<GameObject>("code.unity3d", "Code");
 			byte[] assBytes = code.Get<TextAsset>("Hotfix.dll").bytes;
 			byte[] mdbBytes = code.Get<TextAsset>("Hotfix.mdb").bytes;
 			Assembly assembly = Assembly.Load(assBytes, mdbBytes);

+ 1 - 1
Unity/Hotfix/UI/UILobby/Factory/UILobbyFactory.cs

@@ -13,7 +13,7 @@ namespace Hotfix
 	        {
 				ResourcesComponent resourcesComponent = Game.Scene.GetComponent<ResourcesComponent>();
 		        resourcesComponent.LoadBundle($"{type}.unity3d");
-				GameObject bundleGameObject = resourcesComponent.GetAsset<GameObject>($"{type}", $"{type}");
+				GameObject bundleGameObject = resourcesComponent.GetAsset<GameObject>($"{type}.unity3d", $"{type}");
 				GameObject lobby = UnityEngine.Object.Instantiate(bundleGameObject);
 				lobby.layer = LayerMask.NameToLayer(LayerNames.UI);
 				UI ui = EntityFactory.Create<UI, Scene, UI, GameObject>(scene, null, lobby);

+ 2 - 2
Unity/Hotfix/UI/UILogin/Component/UILoginComponent.cs

@@ -35,11 +35,11 @@ namespace Hotfix
 			{
 				session = Hotfix.Scene.ModelScene.GetComponent<NetOuterComponent>().Create(GlobalConfigComponent.Instance.GlobalProto.Address);
 				string text = this.account.GetComponent<InputField>().text;
-				R2C_Login r2CLogin = await session.Call<R2C_Login>(new C2R_Login() { Account = text, Password = "111111" });
+				R2C_Login r2CLogin = (R2C_Login)await session.Call(new C2R_Login() { Account = text, Password = "111111" });
 				Session gateSession = Hotfix.Scene.ModelScene.GetComponent<NetOuterComponent>().Create(r2CLogin.Address);
 				Game.Scene.AddComponent<SessionComponent>().Session = gateSession;
 
-				G2C_LoginGate g2CLoginGate = await SessionComponent.Instance.Session.Call<G2C_LoginGate>(new C2G_LoginGate() {Key = r2CLogin.Key});
+				G2C_LoginGate g2CLoginGate = (G2C_LoginGate)await SessionComponent.Instance.Session.Call(new C2G_LoginGate() {Key = r2CLogin.Key});
 				Log.Info("登陆gate成功!");
 
 				// 创建Player

+ 1 - 1
Unity/Hotfix/UI/UILogin/Factory/UILoginFactory.cs

@@ -13,7 +13,7 @@ namespace Hotfix
 			{
 				ResourcesComponent resourcesComponent = Game.Scene.GetComponent<ResourcesComponent>();
 				resourcesComponent.LoadBundle($"{type}.unity3d");
-				GameObject bundleGameObject = resourcesComponent.GetAsset<GameObject>($"{type}", $"{type}");
+				GameObject bundleGameObject = resourcesComponent.GetAsset<GameObject>($"{type}.unity3d", $"{type}");
 				GameObject login = UnityEngine.Object.Instantiate(bundleGameObject);
 				login.layer = LayerMask.NameToLayer(LayerNames.UI);
 		        UI ui = EntityFactory.Create<UI, Scene, UI, GameObject>(scene, null, login);

+ 4 - 1
Unity/ProjectSettings/EditorBuildSettings.asset

@@ -4,4 +4,7 @@
 EditorBuildSettings:
   m_ObjectHideFlags: 0
   serializedVersion: 2
-  m_Scenes: []
+  m_Scenes:
+  - enabled: 1
+    path: Assets/Scenes/Init.unity
+    guid: e0d691ac8c1d0454ba07089ea820e18a

+ 1 - 0
Unity/ProjectSettings/ProjectSettings.asset

@@ -571,6 +571,7 @@ PlayerSettings:
   webGLCompressionFormat: 1
   scriptingDefineSymbols:
     1: NET45
+    4: NET45;ASYNC
   platformArchitecture:
     iOS: 2
   scriptingBackend:

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1 - 2
Unity/Unity.Editor.Plugins.csproj


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1 - 2
Unity/Unity.Editor.csproj


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1 - 2
Unity/Unity.Plugins.csproj


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 1 - 2
Unity/Unity.csproj


برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است