Răsfoiți Sursa

Client端配置也放到StartConfig目录,统一由配置编辑器编辑

tanghai 9 ani în urmă
părinte
comite
a9aa7fa8c3

+ 1 - 0
Config/StartConfig/ClientConfig.txt

@@ -0,0 +1 @@
+{ "_t" : "StartConfig", "_id" : NumberLong("96935508377601"), "Type" : 4, "components" : [{ "_t" : "ClientConfig", "_id" : NumberLong("96935508377602"), "Host" : "127.0.0.1", "Port" : 10000 }], "AppId" : 0, "AppType" : "Client", "ServerIP" : "*" }

+ 1 - 1
Server/Model/Component/StartConfigComponent.cs

@@ -7,7 +7,7 @@ using CommandLine;
 namespace Model
 {
 	[ObjectEvent]
-	public class OptionsComponentEvent : ObjectEvent<StartConfigComponent>, IAwake<string[]>
+	public class StartConfigComponentEvent : ObjectEvent<StartConfigComponent>, IAwake<string[]>
 	{
 		public void Awake(string[] args)
 		{

+ 0 - 9
Unity/Assets/Editor/ClientConfigEditor.meta

@@ -1,9 +0,0 @@
-fileFormatVersion: 2
-guid: 44f2bb6ff888c0b4c82e9e5434888b58
-folderAsset: yes
-timeCreated: 1477315157
-licenseType: Pro
-DefaultImporter:
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 60
Unity/Assets/Editor/ClientConfigEditor/ClientConfigEditor.cs

@@ -1,60 +0,0 @@
-using System.IO;
-using Base;
-using Model;
-using UnityEditor;
-using UnityEngine;
-
-namespace MyEditor
-{
-	public class ClientConfigEditor : EditorWindow
-	{
-		private const string Path = "./StartConfig.txt";
-
-		private StartConfig config;
-
-		[MenuItem("Tools/客户端配置")]
-		private static void ShowWindow()
-		{
-			GetWindow(typeof(ClientConfigEditor));
-		}
-
-		private void OnEnable()
-		{
-			if (!File.Exists(Path))
-			{
-				this.config = new StartConfig();
-				this.config.AppType = AppType.Client;
-				this.config.ServerIP = "*";
-				this.config.AddComponent<ClientConfig>();
-				return;
-			}
-
-			string s = File.ReadAllText(Path);
-			this.config = MongoHelper.FromJson<StartConfig>(s);
-		}
-
-		private void OnGUI()
-		{
-			ClientConfig clientConfig = this.config.GetComponent<ClientConfig>();
-			clientConfig.Host = EditorGUILayout.TextField("地址: ", clientConfig.Host);
-			clientConfig.Port = EditorGUILayout.IntField("端口: ", clientConfig.Port);
-			
-			if (GUILayout.Button("保存"))
-			{
-				using (StreamWriter sw = new StreamWriter(new FileStream(Path, FileMode.Create)))
-				{
-					sw.Write(this.config);
-				}
-			}
-		}
-
-		private void OnDisable()
-		{
-		}
-
-		private void OnDestroy()
-		{
-			this.config.Dispose();
-		}
-	}
-}

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

@@ -18,7 +18,7 @@ namespace Model
 
 		public void Awake()
 		{
-			string s = File.ReadAllText("./StartConfig.txt");
+			string s = File.ReadAllText("../Config/StartConfig/ClientConfig.txt");
 			this.Config = MongoHelper.FromJson<StartConfig>(s);
 		}
 

+ 10 - 0
Unity/Assets/Scripts/Component/Config/RunServerConfig.cs

@@ -0,0 +1,10 @@
+using MongoDB.Bson.Serialization.Attributes;
+
+namespace Model
+{
+	[BsonIgnoreExtraElements]
+	public class RunServerConfig: AConfigComponent
+	{
+		public string IP = "";
+	}
+}

+ 2 - 2
Unity/Assets/Editor/ClientConfigEditor/ClientConfigEditor.cs.meta → Unity/Assets/Scripts/Component/Config/RunServerConfig.cs.meta

@@ -1,6 +1,6 @@
 fileFormatVersion: 2
-guid: c96b6436ee16cfd43b0c9600c7fe964a
-timeCreated: 1477315158
+guid: bceb49362f439a248b806059721da628
+timeCreated: 1478834038
 licenseType: Pro
 MonoImporter:
   serializedVersion: 2

+ 1 - 2
Unity/Assets/Scripts/Entity/Config/StartConfig.cs

@@ -1,5 +1,4 @@
-using Base;
-using MongoDB.Bson;
+using MongoDB.Bson;
 using MongoDB.Bson.Serialization.Attributes;
 
 namespace Model

+ 0 - 1
Unity/StartConfig.txt

@@ -1 +0,0 @@
-{ "_t" : "StartConfig", "_id" : NumberLong("96871590002689"), "Type" : "Config", "components" : [{ "_t" : "ClientConfig", "_id" : NumberLong("96871590002690"), "Host" : "127.0.0.1", "Port" : 10000 }], "AppId" : 0, "AppType" : "None", "ServerIP" : null }

+ 2 - 2
Unity/Unity.CSharp.Editor.csproj

@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
@@ -18,6 +18,7 @@
     <UnityBuildTarget>StandaloneWindows:5</UnityBuildTarget>
     <UnityVersion>5.4.1f1</UnityVersion>
     <RootNamespace></RootNamespace>
+    <LangVersion Condition=" '$(VisualStudioVersion)' != '10.0' ">4</LangVersion>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <DebugType>pdbonly</DebugType>
@@ -111,7 +112,6 @@
     </ProjectReference>
   </ItemGroup>
   <ItemGroup>
-    <Compile Include="Assets\Editor\ClientConfigEditor\ClientConfigEditor.cs" />
     <Compile Include="Assets\Editor\EditorInit.cs" />
     <Compile Include="Assets\Editor\ObjectManagerToolsEditor\ObjectManagerToolsWindow.cs" />
     <Compile Include="Assets\Editor\ReferenceCollectorEditor\ReferenceCollectorEditor.cs" />

+ 1 - 0
Unity/Unity.CSharp.csproj

@@ -83,6 +83,7 @@
     <Compile Include="Assets\Scripts\Component\ChildrenComponent.cs" />
     <Compile Include="Assets\Scripts\Component\ClientConfigComponent.cs" />
     <Compile Include="Assets\Scripts\Component\ConfigComponent.cs" />
+    <Compile Include="Assets\Scripts\Component\Config\RunServerConfig.cs" />
     <Compile Include="Assets\Scripts\Component\Config\OuterConfig.cs" />
     <Compile Include="Assets\Scripts\Component\Config\InnerConfig.cs" />
     <Compile Include="Assets\Scripts\Component\Config\ClientConfig.cs" />