Просмотр исходного кода

UI事件回调到IL层,测试OK

tanghai 9 лет назад
Родитель
Сommit
95e79f7810

+ 84 - 0
Unity/Assets/Bundles/UI/Lobby.prefab

@@ -38,6 +38,7 @@ GameObject:
   - 224: {fileID: 224000014261888288}
   - 222: {fileID: 222000013767965188}
   - 114: {fileID: 114000013938780624}
+  - 114: {fileID: 114000011352581290}
   m_Layer: 5
   m_Name: JoinRoom
   m_TagString: Untagged
@@ -55,6 +56,7 @@ GameObject:
   - 224: {fileID: 224000013995298894}
   - 222: {fileID: 222000012286557312}
   - 114: {fileID: 114000010390865150}
+  - 114: {fileID: 114000012431845190}
   m_Layer: 5
   m_Name: CreateRoom
   m_TagString: Untagged
@@ -450,6 +452,47 @@ MonoBehaviour:
     gameObject: {fileID: 1000010654722068}
   - key: JoinRoom
     gameObject: {fileID: 1000010282139360}
+--- !u!114 &114000011352581290
+MonoBehaviour:
+  m_ObjectHideFlags: 1
+  m_PrefabParentObject: {fileID: 0}
+  m_PrefabInternal: {fileID: 100100000}
+  m_GameObject: {fileID: 1000010282139360}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 1392445389, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_Navigation:
+    m_Mode: 3
+    m_SelectOnUp: {fileID: 0}
+    m_SelectOnDown: {fileID: 0}
+    m_SelectOnLeft: {fileID: 0}
+    m_SelectOnRight: {fileID: 0}
+  m_Transition: 1
+  m_Colors:
+    m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
+    m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
+    m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
+    m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
+    m_ColorMultiplier: 1
+    m_FadeDuration: 0.1
+  m_SpriteState:
+    m_HighlightedSprite: {fileID: 0}
+    m_PressedSprite: {fileID: 0}
+    m_DisabledSprite: {fileID: 0}
+  m_AnimationTriggers:
+    m_NormalTrigger: Normal
+    m_HighlightedTrigger: Highlighted
+    m_PressedTrigger: Pressed
+    m_DisabledTrigger: Disabled
+  m_Interactable: 1
+  m_TargetGraphic: {fileID: 114000013938780624}
+  m_OnClick:
+    m_PersistentCalls:
+      m_Calls: []
+    m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0,
+      Culture=neutral, PublicKeyToken=null
 --- !u!114 &114000012146228554
 MonoBehaviour:
   m_ObjectHideFlags: 1
@@ -545,6 +588,47 @@ MonoBehaviour:
   m_FillAmount: 1
   m_FillClockwise: 1
   m_FillOrigin: 0
+--- !u!114 &114000012431845190
+MonoBehaviour:
+  m_ObjectHideFlags: 1
+  m_PrefabParentObject: {fileID: 0}
+  m_PrefabInternal: {fileID: 100100000}
+  m_GameObject: {fileID: 1000010654722068}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 1392445389, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_Navigation:
+    m_Mode: 3
+    m_SelectOnUp: {fileID: 0}
+    m_SelectOnDown: {fileID: 0}
+    m_SelectOnLeft: {fileID: 0}
+    m_SelectOnRight: {fileID: 0}
+  m_Transition: 1
+  m_Colors:
+    m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
+    m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
+    m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
+    m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
+    m_ColorMultiplier: 1
+    m_FadeDuration: 0.1
+  m_SpriteState:
+    m_HighlightedSprite: {fileID: 0}
+    m_PressedSprite: {fileID: 0}
+    m_DisabledSprite: {fileID: 0}
+  m_AnimationTriggers:
+    m_NormalTrigger: Normal
+    m_HighlightedTrigger: Highlighted
+    m_PressedTrigger: Pressed
+    m_DisabledTrigger: Disabled
+  m_Interactable: 1
+  m_TargetGraphic: {fileID: 114000010390865150}
+  m_OnClick:
+    m_PersistentCalls:
+      m_Calls: []
+    m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0,
+      Culture=neutral, PublicKeyToken=null
 --- !u!114 &114000012921558084
 MonoBehaviour:
   m_ObjectHideFlags: 1

+ 9 - 0
Unity/Assets/Scripts/Component/UI.meta

@@ -0,0 +1,9 @@
+fileFormatVersion: 2
+guid: 04aa44487cc12004aaa03a8934ccfb4d
+folderAsset: yes
+timeCreated: 1487388885
+licenseType: Pro
+DefaultImporter:
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 7 - 0
Unity/Assets/Scripts/Component/UI/UILobbyComponent.cs

@@ -0,0 +1,7 @@
+namespace Model
+{
+	[EntityEvent(EntityEventId.UILobbyComponent)]
+	public class UILobbyComponent: Component
+	{
+	}
+}

+ 12 - 0
Unity/Assets/Scripts/Component/UI/UILobbyComponent.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: a1158e7f1ac379c42a1e1fef23c742c9
+timeCreated: 1487389162
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 13 - 0
Unity/Assets/Scripts/Helper/ActionHelper.cs

@@ -0,0 +1,13 @@
+using System;
+using UnityEngine.UI;
+
+namespace Model
+{
+	public static class ActionHelper
+	{
+		public static void Add(this Button.ButtonClickedEvent buttonClickedEvent, Action action)
+		{
+			buttonClickedEvent.AddListener(()=> { action(); });
+		}
+	}
+}

+ 12 - 0
Unity/Assets/Scripts/Helper/ActionHelper.cs.meta

@@ -0,0 +1,12 @@
+fileFormatVersion: 2
+guid: 3ae0366e51013cd4ca6209786d7aaac4
+timeCreated: 1487390785
+licenseType: Pro
+MonoImporter:
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 1 - 0
Unity/Assets/Scripts/Other/EntityEventId.cs

@@ -24,5 +24,6 @@
 		public const int LockComponent = 19;
 		public const int MasterComponent = 20;
 		public const int RealmGateAddressComponent = 21;
+		public const int UILobbyComponent = 22;
 	}
 }

+ 29 - 0
Unity/Hotfix/UI/UILogin/Component/UILobbyComponentE.cs

@@ -0,0 +1,29 @@
+using Base;
+using UnityEngine;
+using UnityEngine.UI;
+
+namespace Model
+{
+	[EntityEvent(EntityEventId.UILobbyComponent)]
+	public static class UILobbyComponentE
+	{
+		public static void Awake(this UILobbyComponent self)
+		{
+			ReferenceCollector rc = self.GetOwner<UI>().GameObject.GetComponent<ReferenceCollector>();
+			GameObject createRoom = rc.Get<GameObject>("CreateRoom");
+			GameObject joinRoom = rc.Get<GameObject>("JoinRoom");
+			createRoom.GetComponent<Button>().onClick.Add(()=> self.OnCreateRoom());
+			joinRoom.GetComponent<Button>().onClick.Add(()=>self.OnJoinRoom());
+		}
+
+		private static void OnCreateRoom(this UILobbyComponent self)
+		{
+			Log.Debug("create room");
+		}
+
+		private static void OnJoinRoom(this UILobbyComponent self)
+		{
+
+		}
+	}
+}

+ 2 - 0
Unity/Hotfix/UI/UILogin/Factory/UILobbyFactory.cs

@@ -15,6 +15,8 @@ namespace Hotfix
 
 			UI ui = new UI(scene, type, parent, lobby);
 			parent.AddChild(ui);
+
+	        ui.AddComponent<UILobbyComponent>();
             
             return ui;
         }

+ 5 - 0
Unity/Hotfix/Unity.Hotfix.csproj

@@ -49,9 +49,14 @@
       <SpecificVersion>False</SpecificVersion>
       <HintPath>..\Library\UnityAssemblies\UnityEngine.dll</HintPath>
     </Reference>
+    <Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+      <SpecificVersion>False</SpecificVersion>
+      <HintPath>..\Library\UnityAssemblies\UnityEngine.UI.dll</HintPath>
+    </Reference>
   </ItemGroup>
   <ItemGroup>
     <Compile Include="Component\UnitComponentE.cs" />
+    <Compile Include="UI\UILogin\Component\UILobbyComponentE.cs" />
     <Compile Include="UI\UILogin\Event\InitSceneStart_CreateLobbyUI.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
     <Compile Include="UI\UILogin\Factory\UILobbyFactory.cs" />

+ 3 - 0
Unity/Unity.csproj

@@ -397,6 +397,7 @@
     <Compile Include="Assets\Scripts\Component\TimeComponent.cs" />
     <Compile Include="Assets\Scripts\Component\TimerComponent.cs" />
     <Compile Include="Assets\Scripts\Component\UIComponent.cs" />
+    <Compile Include="Assets\Scripts\Component\UI\UILobbyComponent.cs" />
     <Compile Include="Assets\Scripts\Component\UnitComponent.cs" />
     <Compile Include="Assets\Scripts\Config\ACategory.cs" />
     <Compile Include="Assets\Scripts\Config\AConfig.cs" />
@@ -425,6 +426,7 @@
     <Compile Include="Assets\Scripts\GameObjectHelper.cs" />
     <Compile Include="Assets\Scripts\Helper\AssetBundleHelper.cs" />
     <Compile Include="Assets\Scripts\Helper\DllHelper.cs" />
+    <Compile Include="Assets\Scripts\Helper\ActionHelper.cs" />
     <Compile Include="Assets\Scripts\Helper\EventHelper.cs" />
     <Compile Include="Assets\Scripts\ILAdaptor\IAsyncStateMachineAdaptor.cs" />
     <Compile Include="Assets\Scripts\ILAdaptor\IUIFactoryAdaptor.cs" />
@@ -486,6 +488,7 @@
     <None Include="Assets\Plugins\Android\ShareSDK\res\values\ssdk_oks_strings.xml" />
     <None Include="Assets\Plugins\Android\ShareSDK\res\values\ssdk_strings.xml" />
   </ItemGroup>
+  <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <Target Name="GenerateTargetFrameworkMonikerAttribute" />
 </Project>