正常情况:

黑屏:

原封不动重新打包后黑屏情况:

每次重新打包出来后被打断的log位置都不同。开始以为ETTask有问题,但修改Init之后并不能解决!
private void Start()
{
Log.Error($“Start_000”);
this.StartInit();
this.StartAsync().Coroutine();
Log.Error($“Start_000”);
}
private void StartInit()
{
try
{
Log.Error($"Start_001");
SynchronizationContext.SetSynchronizationContext(OneThreadSynchronizationContext.Instance);
DontDestroyOnLoad(gameObject);
Log.Error($"Start_002");
Game.EventSystem.Add(DLLType.Model, typeof(Init).Assembly);
//BaseComponent
Log.Error($"Start_003");
Game.Scene.AddComponent<TimerComponent>();
Log.Error($"Start_004");
Game.Scene.AddComponent<GlobalConfigComponent>();
Log.Error($"Start_005");
Game.Scene.AddComponent<NetOuterComponent>();
Game.Scene.AddComponent<ResourcesComponent>();
Game.Scene.AddComponent<ProtoMessageCentreComponent>();
//FUIComponent
Game.Scene.AddComponent<FUIPackageComponent>();
Game.Scene.AddComponent<FUIComponent>();
Game.Scene.AddComponent<FUIInitComponent>();
//GameCompoennt
Game.Scene.AddComponent<UnitCollectionComponent>();
Game.Scene.AddComponent<RoleCollectionComponent>();
Game.Scene.AddComponent<GameControllerComponent>();
//添加游戏功能组件
Game.Scene.AddComponent<AudioComponent>();
Game.EventSystem.Run(EventIdType.InitGameLodingUIEvent);
}
catch (Exception e)
{
Log.Error(e);
}
}
以上频繁出现被断的位置
Start_002
Start_003
Start_004
try
{
Log.Error($"Assembly_01");
this.assemblies[dllType] = assembly;
this.types.Clear();
foreach (Assembly value in this.assemblies.Values)
{
foreach (Type type in value.GetTypes())
{
object[] objects = type.GetCustomAttributes(typeof(BaseAttribute), false);
if (objects.Length == 0)
{
continue;
}
BaseAttribute baseAttribute = (BaseAttribute) objects[0];
this.types.Add(baseAttribute.AttributeType, type);
}
}
this.awakeSystems.Clear();
this.lateUpdateSystems.Clear();
this.updateSystems.Clear();
this.startSystems.Clear();
this.loadSystems.Clear();
this.changeSystems.Clear();
this.destroySystems.Clear();
this.deserializeSystems.Clear();
Log.Error($"Assembly_02");
foreach (Type type in types[typeof(ObjectSystemAttribute)])
{
object[] attrs = type.GetCustomAttributes(typeof(ObjectSystemAttribute), false);
if (attrs.Length == 0)
{
continue;
}
object obj = Activator.CreateInstance(type);
switch (obj)
{
case IAwakeSystem objectSystem:
this.awakeSystems.Add(objectSystem.Type(), objectSystem);
break;
case IUpdateSystem updateSystem:
this.updateSystems.Add(updateSystem.Type(), updateSystem);
break;
case ILateUpdateSystem lateUpdateSystem:
this.lateUpdateSystems.Add(lateUpdateSystem.Type(), lateUpdateSystem);
break;
case IStartSystem startSystem:
this.startSystems.Add(startSystem.Type(), startSystem);
break;
case IDestroySystem destroySystem:
this.destroySystems.Add(destroySystem.Type(), destroySystem);
break;
case ILoadSystem loadSystem:
this.loadSystems.Add(loadSystem.Type(), loadSystem);
break;
case IChangeSystem changeSystem:
this.changeSystems.Add(changeSystem.Type(), changeSystem);
break;
case IDeserializeSystem deserializeSystem:
this.deserializeSystems.Add(deserializeSystem.Type(), deserializeSystem);
break;
}
}
this.allEvents.Clear();
Log.Error($"Assembly_03");
if (types.ContainsKey(typeof(EventAttribute)))
{
foreach (Type type in types[typeof(EventAttribute)])
{
object[] attrs = type.GetCustomAttributes(typeof(EventAttribute), false);
foreach (object attr in attrs)
{
EventAttribute aEventAttribute = (EventAttribute)attr;
object obj = Activator.CreateInstance(type);
IEvent iEvent = obj as IEvent;
if (iEvent == null)
{
Log.Error($"{obj.GetType().Name} 没有继承IEvent");
}
this.RegisterEvent(aEventAttribute.Type, iEvent);
}
}
}
Log.Error($"Assembly_04");
this.Load();
Log.Error($"Assembly_05");
}
catch (Exception e)
{
Log.Error(e);
}
频繁出现位置
Log.Error($“Assembly_02”);
Log.Error($“Assembly_03”);
每次重新打包出现的位置都是不同的。