Skip to content

Commit 24b4c0a

Browse files
committed
fix hotfix uimanager
1 parent 0167c4a commit 24b4c0a

File tree

111 files changed

+60222
-12544
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+60222
-12544
lines changed

Assembly-CSharp-Editor.csproj

Lines changed: 210 additions & 210 deletions
Large diffs are not rendered by default.

Assembly-CSharp.csproj

Lines changed: 188 additions & 188 deletions
Large diffs are not rendered by default.

Assets/Game/HotFix/HotFix.dll.bytes

0 Bytes
Binary file not shown.

Assets/Game/HotFix/HotFix.pdb.bytes

0 Bytes
Binary file not shown.

HotFix/HotFix/GameFramework/UI/UIManager.cs

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ public sealed class UIManager : GameFrameworkModule,IUpdate
2121
//资源管理器
2222
private GameFramework.Taurus.ResourceManager _resource;
2323
//ui堆栈
24-
private Stack<UIViewAttribute> _stackUiAsset = new Stack<UIViewAttribute>();
24+
private Stack<AssetConfig> _stackUiAsset = new Stack<AssetConfig>();
2525
//所有的uiview
26-
private readonly Dictionary<UIViewAttribute, UIView> _allUiViews = new Dictionary<UIViewAttribute, UIView>();
26+
private readonly Dictionary<AssetConfig, UIView> _allUiViews = new Dictionary<AssetConfig, UIView>();
2727
//默认的uipath路径
28-
private readonly Dictionary<int, UIViewAttribute> _uiAssetPath = new Dictionary<int, UIViewAttribute>();
28+
private readonly Dictionary<int, AssetConfig> _uiAssetPath = new Dictionary<int, AssetConfig>();
2929
//所有的uiAsset
30-
private readonly Dictionary<int, UIViewAttribute> _allUiAssets = new Dictionary<int, UIViewAttribute>();
30+
private readonly Dictionary<int, AssetConfig> _allUiAssets = new Dictionary<int, AssetConfig>();
3131
#region 构造函数
3232
public UIManager()
3333
{
@@ -39,17 +39,17 @@ public UIManager()
3939
#region 外部接口
4040
public void Push<T>(bool allowMulti = false, params object[] parameters) where T : UIView
4141
{
42-
UIViewAttribute uiViewAttribute = CheckAssetPath(typeof(T));
43-
if (uiViewAttribute == null)
42+
AssetConfig assetConfig = CheckAssetPath(typeof(T));
43+
if (assetConfig == null)
4444
return;
4545

4646
if (_stackUiAsset.Count > 0)
4747
{
48-
UIViewAttribute lastUiViewAttribute = _stackUiAsset.Peek();
48+
AssetConfig lastAssetCofig = _stackUiAsset.Peek();
4949
//如果界面已经打开 则不在执行
50-
if (Equals(lastUiViewAttribute, uiViewAttribute) && !allowMulti)
50+
if (Equals(lastAssetCofig, assetConfig) && !allowMulti)
5151
return;
52-
IUIView uiView = GetUiView<T>(lastUiViewAttribute);
52+
IUIView uiView = GetUiView<T>(lastAssetCofig);
5353

5454
////触发暂停事件
5555
//_uiPauseArgs.UIView = uiView;
@@ -58,13 +58,15 @@ public void Push<T>(bool allowMulti = false, params object[] parameters) where T
5858
uiView.OnPause();
5959
}
6060

61-
UIViewAttribute newUIViewAttribute = uiViewAttribute;
61+
AssetConfig newAssetConfig = null;
6262
if (allowMulti)
63-
newUIViewAttribute = new UIViewAttribute(uiViewAttribute.AssetBundleName, uiViewAttribute.ViewPath);
63+
newAssetConfig = new AssetConfig(assetConfig.AssetBundleName, assetConfig.AssetPath);
64+
else
65+
newAssetConfig = assetConfig;
6466

6567

66-
_stackUiAsset.Push(newUIViewAttribute);
67-
UIView newUiView = GetUiView<T>(newUIViewAttribute);
68+
_stackUiAsset.Push(newAssetConfig);
69+
UIView newUiView = GetUiView<T>(newAssetConfig);
6870
newUiView.OnEnter(parameters);
6971

7072
////触发打开事件
@@ -78,9 +80,9 @@ public void Pop(bool isDestory = false)
7880
//移除当前UI
7981
if (_stackUiAsset.Count > 0)
8082
{
81-
UIViewAttribute lastUIViewAttribute = _stackUiAsset.Pop();
83+
AssetConfig lastAssetConfig = _stackUiAsset.Pop();
8284
UIView lastUiView;
83-
if (_allUiViews.TryGetValue(lastUIViewAttribute, out lastUiView))
85+
if (_allUiViews.TryGetValue(lastAssetConfig, out lastUiView))
8486
{
8587
////触发关闭事件
8688
//_uiExitArgs.UIView = lastUiView;
@@ -89,7 +91,7 @@ public void Pop(bool isDestory = false)
8991
lastUiView.OnExit();
9092
if (isDestory)
9193
{
92-
_allUiViews.Remove(lastUIViewAttribute);
94+
_allUiViews.Remove(lastAssetConfig);
9395
MonoBehaviour.Destroy(lastUiView.gameObject);
9496
}
9597
else
@@ -99,8 +101,8 @@ public void Pop(bool isDestory = false)
99101

100102
if (_stackUiAsset.Count > 0)
101103
{
102-
UIViewAttribute uiViewAttribute = _stackUiAsset.Peek();
103-
if (_allUiViews.TryGetValue(uiViewAttribute, out var lastUiView))
104+
AssetConfig lastAssetConfig = _stackUiAsset.Peek();
105+
if (_allUiViews.TryGetValue(lastAssetConfig, out var lastUiView))
104106
lastUiView.OnResume();
105107

106108
////触发恢复事件
@@ -125,32 +127,31 @@ public void OnUpdate()
125127
}
126128

127129
//检查路径
128-
private UIViewAttribute CheckAssetPath(Type t)
130+
private AssetConfig CheckAssetPath(Type t)
129131
{
130132
int hashCode = t.GetHashCode();
131133

132-
UIViewAttribute uiViewAttribute = null;
133-
if (!_uiAssetPath.TryGetValue(hashCode, out uiViewAttribute))
134+
if (!_uiAssetPath.TryGetValue(hashCode, out var assetCofig))
134135
{
135136
object[] attrs = t.GetCustomAttributes(typeof(UIViewAttribute), false);
136137
if (attrs.Length == 0)
137138
return null;
138-
uiViewAttribute = (UIViewAttribute)attrs[0];
139-
if (string.IsNullOrEmpty(uiViewAttribute.ViewPath)
140-
|| string.IsNullOrEmpty(uiViewAttribute.AssetBundleName))
139+
if (!(attrs[0] is UIViewAttribute uIViewAttribute)||string.IsNullOrEmpty(uIViewAttribute.ViewPath)
140+
|| string.IsNullOrEmpty(uIViewAttribute.AssetBundleName))
141141
return null;
142+
assetCofig = new AssetConfig(uIViewAttribute.AssetBundleName, uIViewAttribute.ViewPath);
142143
}
143-
return uiViewAttribute;
144+
return assetCofig;
144145
}
145146

146147

147148
//获取ui界面
148-
private UIView GetUiView<T>(UIViewAttribute uiViewAttribute) where T:UIView
149+
private UIView GetUiView<T>(AssetConfig assetConfig) where T:UIView
149150
{
150151
UIView uiView;
151-
if (!_allUiViews.TryGetValue(uiViewAttribute, out uiView))
152+
if (!_allUiViews.TryGetValue(assetConfig, out uiView))
152153
{
153-
GameObject uiViewSource = _resource.LoadAsset<GameObject>(uiViewAttribute.AssetBundleName, uiViewAttribute.ViewPath);
154+
GameObject uiViewSource = _resource.LoadAsset<GameObject>(assetConfig.AssetBundleName, assetConfig.AssetPath);
154155
if (uiViewSource == null)
155156
return null;
156157
GameObject uiViewClone = GameObject.Instantiate(uiViewSource);
@@ -163,7 +164,7 @@ private UIView GetUiView<T>(UIViewAttribute uiViewAttribute) where T:UIView
163164
if (ci != null) uiView = ci.Invoke(obj) as UIView;
164165
if (uiView == null)
165166
return null;
166-
_allUiViews[uiViewAttribute] = uiView;
167+
_allUiViews[assetConfig] = uiView;
167168
return uiView;
168169
}
169170
uiView.gameObject.SetActive(true);
@@ -187,7 +188,23 @@ public override void OnClose()
187188
_allUiViews.Clear();
188189
}
189190
#endregion
190-
191+
192+
193+
private class AssetConfig
194+
{
195+
public string AssetBundleName;
196+
public string AssetPath;
197+
198+
public AssetConfig()
199+
{
200+
}
201+
202+
public AssetConfig(string assetBundleName, string assetPath)
203+
{
204+
AssetBundleName = assetBundleName;
205+
AssetPath = assetPath;
206+
}
207+
}
191208

192209

193210
}

HotFix/HotFix/HotFix.csproj

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,19 @@
4545
<Reference Include="System.Data.DataSetExtensions" />
4646
<Reference Include="System.Data" />
4747
<Reference Include="System.Xml" />
48-
<Reference Include="UnityEngine.CoreModule">
49-
<HintPath>F:\Program Files\Unity 2017.2.0\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll</HintPath>
48+
<Reference Include="UnityEngine">
49+
<HintPath>F:\Program Files\Unity2018.2.0f2\Editor\Data\Managed\UnityEngine\UnityEngine.dll</HintPath>
5050
</Reference>
51-
<Reference Include="UnityEngine.UI">
52-
<HintPath>F:\Program Files\Unity 2017.2.0\Editor\Data\UnityExtensions\Unity\GUISystem\UnityEngine.UI.dll</HintPath>
51+
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
52+
<SpecificVersion>False</SpecificVersion>
53+
<HintPath>F:\Program Files\Unity2018.2.0f2\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll</HintPath>
54+
</Reference>
55+
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
56+
<SpecificVersion>False</SpecificVersion>
57+
<HintPath>F:\Program Files\Unity2018.2.0f2\Editor\Data\UnityExtensions\Unity\GUISystem\UnityEngine.UI.dll</HintPath>
58+
</Reference>
59+
<Reference Include="UnityEngine.UIModule">
60+
<HintPath>F:\Program Files\Unity2018.2.0f2\Editor\Data\Managed\UnityEngine\UnityEngine.UIModule.dll</HintPath>
5361
</Reference>
5462
</ItemGroup>
5563
<ItemGroup>
0 Bytes
Binary file not shown.

HotFix/HotFix/bin/Debug/HotFix.dll

0 Bytes
Binary file not shown.

HotFix/HotFix/bin/Debug/HotFix.pdb

0 Bytes
Binary file not shown.
42.5 KB
Binary file not shown.

0 commit comments

Comments
 (0)