Skip to content

Commit cecd1be

Browse files
committed
修复若干问题
1 parent 8676127 commit cecd1be

5 files changed

Lines changed: 64 additions & 9 deletions

File tree

Assets/Script/Core/Application/ApplicationManager.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ public void AppLaunch()
116116
public static ApplicationBoolCallback s_OnApplicationFocus = null;
117117
public static ApplicationVoidCallback s_OnApplicationUpdate = null;
118118
public static ApplicationVoidCallback s_OnApplicationOnGUI = null;
119+
public static ApplicationVoidCallback s_OnApplicationOnDrawGizmos = null;
119120

120121
void OnApplicationQuit()
121122
{
@@ -178,9 +179,15 @@ void OnGUI()
178179
s_OnApplicationOnGUI();
179180
}
180181

181-
#endregion
182+
private void OnDrawGizmos()
183+
{
184+
if (s_OnApplicationOnDrawGizmos != null)
185+
s_OnApplicationOnDrawGizmos();
186+
}
187+
188+
#endregion
182189

183-
#region 程序启动细节
190+
#region 程序启动细节
184191
/// <summary>
185192
/// 设置资源加载方式
186193
/// </summary>

Assets/Script/Core/Editor/Network/Protocol/ProtocolHelper.cs

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class ProtocolHelper
1414
{
1515
static List<Type> ModuleList = new List<Type>();
1616
static List<Type> msgList = new List<Type>();
17+
static List<Type> StructList = new List<Type>();
1718

1819
public const string PathName = "ProtocolGenerate";
1920
const string AnalysisCodeName = "ProtocolAnalysisService";
@@ -34,6 +35,8 @@ static void StartGenerate()
3435
string protocolContent = GeneratePrototalContent();
3536
string protocolList = GeneratePrototalList();
3637

38+
Debug.Log(protocolContent);
39+
3740
string ProtocolSavePath = Application.dataPath + "/Resources/Network/" + ProtocolService.c_ProtocolFileName + ".txt";
3841
ResourceIOTool.WriteStringByFile(ProtocolSavePath, protocolContent);
3942

@@ -146,7 +149,7 @@ static string GenerateProtocolMessageField(FieldInfo field, ref int count)
146149
}
147150
else if (field.FieldType.Name == typeof(List<>).Name)
148151
{
149-
string content = "repeated";
152+
string content = "repeated ";
150153
Type type = field.FieldType.GetGenericArguments()[0];
151154

152155
content += GetTypeName(type) + " " + GenerateProtocolFieldName(field) + " = " + count++ + ";\n";
@@ -189,7 +192,7 @@ static string GetTypeName(Type type)
189192
{
190193
return "int8";
191194
}
192-
else if (type.IsSubclassOf(typeof(Enum)))
195+
else if (type == typeof(string))
193196
{
194197
return "string";
195198
}
@@ -312,6 +315,9 @@ static void GenerateProtocolToCsharp()
312315
else
313316
{
314317
string className = GetMessageNmae(item.Value);
318+
319+
//Debug.Log(className + " -> " + item.Value);
320+
315321
if (GetAimType(className) == null)
316322
{
317323
string name = "m_" + item.Value + "_c";
@@ -356,7 +362,14 @@ static void GenerateProtocolToCsharp()
356362
output += GetTab(1) + "#region Struct\n";
357363
for (int i = 0; i < s_SubStruct.Count; i++)
358364
{
359-
output += GenerateProtocolClass(2,SendMode.Both,null, s_SubStruct[i], protocolInfo[s_SubStruct[i]],true);
365+
try
366+
{
367+
output += GenerateProtocolClass(2, SendMode.Both, null, s_SubStruct[i], protocolInfo[s_SubStruct[i]], true);
368+
}
369+
catch
370+
{
371+
throw new Exception("s_SubStruct[i] ->" + s_SubStruct[i]);
372+
}
360373
}
361374
output += GetTab(1) + "#endregion \n";
362375

@@ -401,7 +414,7 @@ static string GenerateProtocolClass(int tab,SendMode mode,string ModuleName, str
401414

402415
if(isStruct)
403416
{
404-
content = GetTab(tab) + "public class " + ClassName + " \n";
417+
content = GetTab(tab) + "public class " + ClassName + " : IProtocolStructInterface \n";
405418
}
406419
else
407420
{
@@ -567,6 +580,11 @@ static string GetMessageNmae(string name)
567580
}
568581
}
569582

583+
if(result == "")
584+
{
585+
return name;
586+
}
587+
570588
return result;
571589
}
572590

@@ -614,6 +632,16 @@ static void GenerateList()
614632

615633
//进行排序
616634
msgList.Sort(sort);
635+
636+
StructList.Clear();
637+
638+
for (int i = 0; i < types.Length; i++)
639+
{
640+
if (typeof(IProtocolStructInterface).IsAssignableFrom(types[i]))
641+
{
642+
StructList.Add(types[i]);
643+
}
644+
}
617645
}
618646

619647
static string GenerateCSharpContent()
@@ -808,6 +836,14 @@ static string GeneratePrototalContent()
808836
content += "\n";
809837
}
810838

839+
Debug.Log("StructList " + StructList.Count);
840+
841+
for (int i = 0; i < StructList.Count; i++)
842+
{
843+
content += "message " + GenerateProtocolName(StructList[i]) + "\n";
844+
content += GenerateProtocolMessageNoHead(StructList[i]);
845+
}
846+
811847
return content;
812848
}
813849

Assets/Script/Core/GuideSystem/GuideSystemBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,10 @@ void StartGuide()
306306

307307
ApplicationManager.s_OnApplicationUpdate += Update;
308308

309+
OnStart();
310+
309311
SetCurrent(LoadFirstGuide());
310312
GuideLogic();
311-
312-
OnStart();
313313
}
314314

315315
void EndGuide()

Assets/Script/Core/Network/Protocol/ProtocolService.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,6 +1249,11 @@ public enum SendMode
12491249
/// </summary>
12501250
public interface IProtocolMessageInterface { }
12511251

1252+
/// <summary>
1253+
/// 自动被Protocol解析的结构
1254+
/// </summary>
1255+
public interface IProtocolStructInterface { }
1256+
12521257
/// <summary>
12531258
///
12541259
/// </summary>

Assets/Script/Core/UI/Model/UIBase.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,14 @@ public GameObject GetGameObject(string name)
155155

156156
if (m_objects.ContainsKey(name))
157157
{
158-
return m_objects[name];
158+
GameObject go = m_objects[name];
159+
160+
if (go == null)
161+
{
162+
throw new Exception("UIWindowBase GetGameObject error: " + UIName + " m_objects[" + name + "] is null !!");
163+
}
164+
165+
return go;
159166
}
160167
else
161168
{

0 commit comments

Comments
 (0)