Skip to content
This repository was archived by the owner on Jul 11, 2023. It is now read-only.

Commit 23ab08d

Browse files
committed
在resuorce添加宏
1 parent de7555c commit 23ab08d

File tree

8 files changed

+116
-7
lines changed

8 files changed

+116
-7
lines changed

Assets/Game/HotFix/HotFix.dll.bytes

-512 Bytes
Binary file not shown.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//-----------------------------------------------------------------------
2+
// <copyright>
3+
// Copyright (c) 2018 Zhang Yang. All rights reserved.
4+
// </copyright>
5+
// <describe> #复制 hotfix dll# </describe>
6+
// <email> [email protected] </email>
7+
// <time> #2018年6月25日 18点03分# </time>
8+
//-----------------------------------------------------------------------
9+
10+
using System.Collections;
11+
using System.Collections.Generic;
12+
using UnityEngine;
13+
using UnityEditor;
14+
using System.IO;
15+
16+
public class HotFixBuildEditor {
17+
18+
private const string _srcDllPath = "Library/ScriptAssemblies/HotFix.dll";
19+
//pdb...
20+
21+
private const string _destDllPath = "Assets/Game/HotFix/HotFix.dll.bytes";
22+
23+
24+
[InitializeOnLoadMethod]
25+
static void Main()
26+
{
27+
//复制dll
28+
File.Copy(_srcDllPath, _destDllPath, true);
29+
30+
//刷新资源
31+
AssetDatabase.Refresh();
32+
33+
Debug.Log($"更新HotFix.dll!{_srcDllPath}-->{_destDllPath}");
34+
}
35+
36+
}

Assets/Game/Scripts/Editor/HotFixBuildEditor.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Game/Scripts/Editor/Module/ResourceModuleEditor.cs

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,32 @@ namespace GameFramework.Taurus
1616
{
1717
public class ResourceModuleEditor : ModuleEditorBase
1818
{
19+
private BuildTargetGroup _lastBuildTargetGroup;
20+
private string _lastScriptingDefineSymbols;
21+
1922
public ResourceModuleEditor(string name, Color mainColor, GameMode gameMode)
2023
: base(name, mainColor, gameMode)
2124
{
22-
25+
//获取当前的BuildTargetGroup
26+
_lastBuildTargetGroup = ConvertBuildTarget(EditorUserBuildSettings.activeBuildTarget);
27+
_lastScriptingDefineSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(_lastBuildTargetGroup);
2328
}
2429

2530
public override void OnDrawGUI()
2631
{
2732
GUILayout.BeginVertical("HelpBox");
2833

34+
GUILayout.BeginHorizontal("HelpBox");
35+
GUILayout.Label("Define",GUILayout.Width(50));
36+
string scriptingDefineSymbols = PlayerSettings.GetScriptingDefineSymbolsForGroup(_lastBuildTargetGroup);
37+
_lastScriptingDefineSymbols = GUILayout.TextArea(_lastScriptingDefineSymbols);
38+
if (GUILayout.Button("OK",GUILayout.Width(40))&&!_lastScriptingDefineSymbols.Equals(scriptingDefineSymbols))
39+
{
40+
_lastBuildTargetGroup = ConvertBuildTarget(EditorUserBuildSettings.activeBuildTarget);
41+
PlayerSettings.SetScriptingDefineSymbolsForGroup(_lastBuildTargetGroup, _lastScriptingDefineSymbols);
42+
}
43+
GUILayout.EndHorizontal();
44+
2945
_gameMode.ResUpdateType =
3046
(ResourceUpdateType)EditorGUILayout.EnumPopup("Resource Update Type", _gameMode.ResUpdateType);
3147
if (_gameMode.ResUpdateType != ResourceUpdateType.Editor)
@@ -63,7 +79,7 @@ public override void OnDrawGUI()
6379

6480
EditorGUILayout.LabelField("Path", path);
6581
}
66-
82+
6783
GUILayout.EndVertical();
6884
}
6985

@@ -72,5 +88,42 @@ public override void OnClose()
7288
{
7389
}
7490

91+
static BuildTargetGroup ConvertBuildTarget(BuildTarget buildTarget)
92+
{
93+
switch (buildTarget)
94+
{
95+
case BuildTarget.StandaloneOSX:
96+
case BuildTarget.iOS:
97+
return BuildTargetGroup.iOS;
98+
case BuildTarget.StandaloneWindows:
99+
case BuildTarget.StandaloneLinux:
100+
case BuildTarget.StandaloneWindows64:
101+
case BuildTarget.StandaloneLinux64:
102+
case BuildTarget.StandaloneLinuxUniversal:
103+
return BuildTargetGroup.Standalone;
104+
case BuildTarget.Android:
105+
return BuildTargetGroup.Android;
106+
case BuildTarget.WebGL:
107+
return BuildTargetGroup.WebGL;
108+
case BuildTarget.WSAPlayer:
109+
return BuildTargetGroup.WSA;
110+
case BuildTarget.PSP2:
111+
return BuildTargetGroup.PSP2;
112+
case BuildTarget.PS4:
113+
return BuildTargetGroup.PS4;
114+
case BuildTarget.XboxOne:
115+
return BuildTargetGroup.XboxOne;
116+
case BuildTarget.N3DS:
117+
return BuildTargetGroup.N3DS;
118+
case BuildTarget.tvOS:
119+
return BuildTargetGroup.tvOS;
120+
case BuildTarget.Switch:
121+
return BuildTargetGroup.Switch;
122+
case BuildTarget.NoTarget:
123+
default:
124+
return BuildTargetGroup.Standalone;
125+
}
126+
}
127+
75128
}
76129
}

Assets/Game/Scripts/State/LoadHotfixState.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private void LoadHotFix()
5656
byte[] dllDatas = GameMode.Resource.LoadAsset<TextAsset>("hotfix",_dllPath).bytes;
5757
byte[] pdbDatas = null;
5858
#if UNITY_EDITOR
59-
pdbDatas = GameMode.Resource.LoadAsset<TextAsset>("hotfix", _pdbPath)?.bytes;
59+
//pdbDatas = GameMode.Resource.LoadAsset<TextAsset>("hotfix", _pdbPath)?.bytes;
6060
GameMode.HotFix.Appdomain.DebugService.StartDebugService(56000);
6161
#endif
6262
GameMode.HotFix.LoadHotfixAssembly(dllDatas, pdbDatas);

Assets/HotFix/Game/State/HotFixTestState.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ public override void OnEnter(params object[] parameters)
99
{
1010
base.OnEnter(parameters);
1111

12+
string str = "asset hotfix xx test";
13+
1214
Debug.Log("HotFixTestState--Start!!");
1315

14-
HotFixMode.Network.SetPort(35120);
16+
Debug.Log(str);
17+
18+
//HotFixMode.Network.SetPort(35120);
1519
}
1620

1721
public override void OnExit()

Assets/HotFix/GameFramework/State/GameStateManager.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void CreateContext(Type[] types)
4242
{
4343
if (_stateContext != null)
4444
return;
45-
45+
UnityEngine.Debug.Log(types.Length);
4646
GameStateContext stateContext = new GameStateContext();
4747
List<GameState> listState = new List<GameState>();
4848

@@ -51,8 +51,12 @@ public void CreateContext(Type[] types)
5151
object[] attribute = item.GetCustomAttributes(typeof(GameStateAttribute), false);
5252
if (attribute.Length <= 0 || item.IsAbstract)
5353
continue;
54-
GameStateAttribute stateAttribute = (GameStateAttribute)attribute[0];
55-
if (stateAttribute.StateType == GameStateType.Ignore)
54+
55+
GameStateAttribute stateAttribute = attribute[0] as GameStateAttribute;
56+
if (stateAttribute == null)
57+
continue;
58+
59+
if (stateAttribute.StateType == GameStateType.Ignore)
5660
continue;
5761
object obj = Activator.CreateInstance(item);
5862
GameState gs = obj as GameState;

Main.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
<ItemGroup>
6363
<Compile Include="Assets\Game\Scripts\Base\GameMode.cs" />
6464
<Compile Include="Assets\Game\Scripts\Editor\GameModeEditor.cs" />
65+
<Compile Include="Assets\Game\Scripts\Editor\HotFixBuildEditor.cs" />
6566
<Compile Include="Assets\Game\Scripts\Editor\Module\ResourceModuleEditor.cs" />
6667
<Compile Include="Assets\Game\Scripts\Editor\Module\SettingModuleEditor.cs" />
6768
<Compile Include="Assets\Game\Scripts\Editor\Module\StateModuleEditor.cs" />

0 commit comments

Comments
 (0)