Sfoglia il codice sorgente

1.UI类可以Get子Gameobject,作为自己的孩子UI
2.修复Hotfix ILRuntime宏没去掉的问题

tanghai 8 anni fa
parent
commit
9f50a32375

+ 9 - 0
Unity/Assets/ThirdParty/ILRuntime/Mono.Cecil.Mdb.meta

@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 7009bf06a68e5594dbd9d52f601ec08a
+folderAsset: yes
+timeCreated: 1509540093
+licenseType: Free
+DefaultImporter:
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 3 - 0
Unity/Assets/ThirdParty/ILRuntime/Mono.Cecil.Mdb/mdb.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: a904e30b95ce4008bfa38291917fba7e
+timeCreated: 1509538086

+ 3 - 0
Unity/Assets/ThirdParty/ILRuntime/Mono.Cecil.Mdb/mdb/Mono.Cecil.Mdb.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 8c01944eba5c4312bc36ab97974848a8
+timeCreated: 1509538086

+ 3 - 0
Unity/Assets/ThirdParty/ILRuntime/Mono.Cecil.Mdb/mdb/Mono.CompilerServices.SymbolWriter.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 7dc3339561a540edaaa26bfa8063908e
+timeCreated: 1509538086

+ 45 - 19
Unity/Hotfix/Entity/UI.cs

@@ -1,15 +1,22 @@
 using System.Collections.Generic;
-using Model;
 using UnityEngine;
 
 namespace Hotfix
 {
+	[Model.ObjectEvent]
+	public class UIEvent : ObjectEvent<UI>, IAwake<Scene, UI, GameObject>
+	{
+		public void Awake(Scene scene, UI parent, GameObject gameObject)
+		{
+			this.Get().Awake(scene, parent, gameObject);
+		}
+	}
+	
+	
 	public sealed class UI: Entity
 	{
 		public Scene Scene { get; set; }
 
-		public UIType UIType { get; }
-
 		public string Name
 		{
 			get
@@ -18,9 +25,22 @@ namespace Hotfix
 			}
 		}
 
-		public GameObject GameObject { get; }
+		public GameObject GameObject { get; private set; }
 
 		public Dictionary<string, UI> children = new Dictionary<string, UI>();
+		
+		public void Awake(Scene scene, UI parent, GameObject gameObject)
+		{
+			this.children.Clear();
+			
+			this.Scene = scene;
+
+			if (parent != null)
+			{
+				gameObject.transform.SetParent(parent.GameObject.transform, false);
+			}
+			this.GameObject = gameObject;
+		}
 
 		public override void Dispose()
 		{
@@ -28,15 +48,16 @@ namespace Hotfix
 			{
 				return;
 			}
-
+			
 			base.Dispose();
 
 			foreach (UI ui in this.children.Values)
 			{
 				ui.Dispose();
 			}
-
-			UnityEngine.Object.Destroy(this.GameObject);
+			
+			UnityEngine.Object.Destroy(GameObject);
+			children.Clear();
 		}
 
 		public void SetAsFirstSibling()
@@ -44,18 +65,6 @@ namespace Hotfix
 			this.GameObject.transform.SetAsFirstSibling();
 		}
 
-		public UI(Scene scene, UIType uiType, UI parent, GameObject gameObject)
-		{
-			this.Scene = scene;
-			this.UIType = uiType;
-
-			if (parent != null)
-			{
-				gameObject.transform.SetParent(parent.GameObject.transform, false);
-			}
-			this.GameObject = gameObject;
-		}
-
 		public void Add(UI ui)
 		{
 			this.children.Add(ui.Name, ui);
@@ -71,5 +80,22 @@ namespace Hotfix
 			this.children.Remove(name);
 			ui.Dispose();
 		}
+
+		public UI Get(string name)
+		{
+			UI child;
+			if (this.children.TryGetValue(name, out child))
+			{
+				return child;
+			}
+			GameObject childGameObject = this.GameObject.transform.Find(name)?.gameObject;
+			if (childGameObject == null)
+			{
+				return null;
+			}
+			child = EntityFactory.Create<UI, Scene, UI, GameObject>(this.Scene, this, childGameObject);
+			this.Add(child);
+			return child;
+		}
 	}
 }

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

@@ -14,7 +14,7 @@ namespace Hotfix
 				GameObject bundleGameObject = ((GameObject)Resources.Load("UI")).Get<GameObject>("UILobby");
 				GameObject lobby = UnityEngine.Object.Instantiate(bundleGameObject);
 				lobby.layer = LayerMask.NameToLayer(LayerNames.UI);
-				UI ui = new UI(scene, type, null, lobby);
+				UI ui = EntityFactory.Create<UI, Scene, UI, GameObject>(scene, null, lobby);
 
 				ui.AddComponent<UILobbyComponent>();
 				return ui;

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

@@ -12,9 +12,9 @@ namespace Hotfix
 	        try
 	        {
 				GameObject bundleGameObject = ((GameObject)Resources.Load("UI")).Get<GameObject>("UILogin");
-				GameObject lobby = UnityEngine.Object.Instantiate(bundleGameObject);
-				lobby.layer = LayerMask.NameToLayer(LayerNames.UI);
-				UI ui = new UI(scene, type, null, lobby);
+				GameObject login = UnityEngine.Object.Instantiate(bundleGameObject);
+				login.layer = LayerMask.NameToLayer(LayerNames.UI);
+		        UI ui = EntityFactory.Create<UI, Scene, UI, GameObject>(scene, null, login);
 
 				ui.AddComponent<UILoginComponent>();
 				return ui;

+ 1 - 1
Unity/Hotfix/Unity.Hotfix.csproj

@@ -29,7 +29,7 @@
     <DebugType>pdbonly</DebugType>
     <Optimize>false</Optimize>
     <OutputPath>..\Temp\UnityVS_bin\Release\</OutputPath>
-    <DefineConstants>TRACE;ILRuntime</DefineConstants>
+    <DefineConstants>TRACE</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
     <Prefer32Bit>false</Prefer32Bit>

+ 6 - 1
Unity/Unity.sln

@@ -1,6 +1,8 @@
 
 Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 2017
+# Visual Studio 15
+VisualStudioVersion = 15.0.27004.2006
+MinimumVisualStudioVersion = 10.0.40219.1
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Plugins", "Unity.Plugins.csproj", "{D1FDB199-0FB7-099D-3771-C6A942E4E326}"
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity", "Unity.csproj", "{CF118143-7E37-744F-BE45-3F55345FEC40}"
@@ -41,4 +43,7 @@ Global
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
 	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+		SolutionGuid = {8AAB8C81-7B77-4817-A4EA-BBC4628E4FA0}
+	EndGlobalSection
 EndGlobal

+ 1 - 0
Unity/Unity.sln.DotSettings.user

@@ -1,4 +1,5 @@
 <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
 	<s:String x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/IntelliSenseCompletingCharacters/CSharpCompletingCharacters/NonCompletingCharacters/@EntryValue"></s:String>
+	<s:String x:Key="/Default/CodeInspection/Highlighting/AnalysisEnabled/@EntryValue">VISIBLE_FILES</s:String>
 	<s:Int64 x:Key="/Default/Environment/SearchAndNavigation/DefaultOccurrencesGroupingIndex/@EntryValue">0</s:Int64>
 	<s:String x:Key="/Default/Housekeeping/Layout/DialogWindows/RefactoringWizardWindow/Location/@EntryValue">247,-4</s:String></wpf:ResourceDictionary>