提交 02718b27 编写于 作者: T tanghai

服务端将一些方法拆分出来,做成System,符合ECS设计,并且System是可以hotfix的

上级 66e13b40
......@@ -12,7 +12,7 @@ namespace Hotfix
try
{
Unit unit = EntityFactory.Create<Unit, UnitType>(UnitType.Hero);
await unit.AddComponent<ActorComponent>().AddLocation();
await unit.AddComponent<ActorComponent, IEntityActorHandler>(new MapUnitEntityActorHandler()).AddLocation();
unit.AddComponent<UnitGateComponent, long>(message.GateSessionId);
Game.Scene.GetComponent<UnitComponent>().Add(unit);
response.UnitId = unit.Id;
......
......@@ -4,12 +4,14 @@ namespace Hotfix
{
public static class MessageHelper
{
public static void Broadcast<Message>(Message message) where Message: AMessage
public static void Broadcast(AActorMessage message)
{
Player[] players = Game.Scene.GetComponent<PlayerComponent>().GetAll();
foreach (Player gamer in players)
Unit[] units = Game.Scene.GetComponent<UnitComponent>().GetAll();
ActorProxyComponent actorProxyComponent = Game.Scene.GetComponent<ActorProxyComponent>();
foreach (Unit unit in units)
{
gamer.GetComponent<SessionInfoComponent>().Session.Send(message);
long gateSessionId = unit.GetComponent<UnitGateComponent>().GateSessionId;
actorProxyComponent.Get(gateSessionId).Send(message);
}
}
}
......
using System.Threading.Tasks;
using Model;
namespace Hotfix
{
/// <summary>
/// gate session 收到的消息直接转发给客户端
/// </summary>
public class GateSessionEntityActorHandler : IEntityActorHandler
{
public async Task Handle(Session session, Entity entity, ActorRequest message)
{
((Session)entity).Send(message.AMessage);
ActorResponse response = new ActorResponse
{
RpcId = message.RpcId
};
session.Reply(response);
}
}
public class CommonEntityActorHandler : IEntityActorHandler
{
public async Task Handle(Session session, Entity entity, ActorRequest message)
{
await Game.Scene.GetComponent<ActorMessageDispatherComponent>().Handle(session, entity, message);
}
}
/// <summary>
/// 玩家收到帧同步消息交给帧同步组件处理
/// </summary>
public class MapUnitEntityActorHandler : IEntityActorHandler
{
public async Task Handle(Session session, Entity entity, ActorRequest message)
{
if (message.AMessage is AFrameMessage aFrameMessage)
{
Game.Scene.GetComponent<ServerFrameComponent>().Add(aFrameMessage);
}
await Game.Scene.GetComponent<ActorMessageDispatherComponent>().Handle(session, entity, message);
}
}
}
\ No newline at end of file
using System;
using Model;
namespace Model
namespace Hotfix
{
public class InnerMessageDispatcher: IMessageDispatcher
{
......
using System;
using Model;
namespace Model
namespace Hotfix
{
public class OuterMessageDispatcher: IMessageDispatcher
{
......
......@@ -34,7 +34,6 @@
<Reference Include="System.Core" />
</ItemGroup>
<ItemGroup>
<Compile Include="Component\RealmGateAddressComponentE.cs" />
<Compile Include="Handler\M2M_TrasferUnitRequest.cs" />
<Compile Include="Handler\Actor_TransferHandler.cs" />
<Compile Include="Handler\Actor_TestRequestHandler.cs" />
......@@ -58,8 +57,16 @@
<Compile Include="Handler\C2M_ReloadHandler.cs" />
<Compile Include="Handler\G2G_LockRequestHandler.cs" />
<Compile Include="Handler\R2G_GetLoginKeyHandler.cs" />
<Compile Include="Other\EntityActorHandler.cs" />
<Compile Include="Other\InnerMessageDispatcher.cs" />
<Compile Include="Other\OuterMessageDispatcher.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Handler\C2R_LoginHandler.cs" />
<Compile Include="System\ActorSystem.cs" />
<Compile Include="System\NetInnerSystem.cs" />
<Compile Include="System\NetOuterSystem.cs" />
<Compile Include="System\RealmGateAddressSystem.cs" />
<Compile Include="System\ServerFrameSystem.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Base\Server.Base.csproj">
......
using System;
using System.Threading.Tasks;
using Model;
namespace Hotfix
{
[ObjectEvent]
public class ActorComponentEvent : ObjectEvent<ActorComponent>, IAwake, IAwake<IEntityActorHandler>
{
public void Awake()
{
this.Get().Awake();
}
public void Awake(IEntityActorHandler iEntityActorHandler)
{
this.Get().Awake(iEntityActorHandler);
}
}
/// <summary>
/// 挂上这个组件表示该Entity是一个Actor, 它会将Entity位置注册到Location Server, 接收的消息将会队列处理
/// </summary>
public static class ActorSystem
{
public static void Awake(this ActorComponent self)
{
self.entityActorHandler = new CommonEntityActorHandler();
self.queue = new EQueue<ActorMessageInfo>();
self.actorId = self.Entity.Id;
Game.Scene.GetComponent<ActorManagerComponent>().Add(self.Entity);
self.HandleAsync();
}
public static void Awake(this ActorComponent self, IEntityActorHandler iEntityActorHandler)
{
self.entityActorHandler = iEntityActorHandler;
self.queue = new EQueue<ActorMessageInfo>();
self.actorId = self.Entity.Id;
Game.Scene.GetComponent<ActorManagerComponent>().Add(self.Entity);
self.HandleAsync();
}
public static async Task AddLocation(this ActorComponent self)
{
await Game.Scene.GetComponent<LocationProxyComponent>().Add(self.actorId);
}
public static async Task RemoveLocation(this ActorComponent self)
{
await Game.Scene.GetComponent<LocationProxyComponent>().Remove(self.actorId);
}
public static void Add(this ActorComponent self, ActorMessageInfo info)
{
self.queue.Enqueue(info);
if (self.tcs == null)
{
return;
}
var t = self.tcs;
self.tcs = null;
t.SetResult(self.queue.Dequeue());
}
private static Task<ActorMessageInfo> GetAsync(this ActorComponent self)
{
if (self.queue.Count > 0)
{
return Task.FromResult(self.queue.Dequeue());
}
self.tcs = new TaskCompletionSource<ActorMessageInfo>();
return self.tcs.Task;
}
private static async void HandleAsync(this ActorComponent self)
{
while (true)
{
try
{
ActorMessageInfo info = await self.GetAsync();
await self.entityActorHandler.Handle(info.Session, self.Entity, info.Message);
}
catch (Exception e)
{
Log.Error(e.ToString());
}
}
}
}
}
\ No newline at end of file
using Model;
namespace Hotfix
{
[ObjectEvent]
public class NetInnerComponentEvent : ObjectEvent<NetInnerComponent>, IAwake, IAwake<string, int>, IUpdate
{
public void Awake()
{
this.Get().Awake();
}
public void Awake(string a, int b)
{
this.Get().Awake(a, b);
}
public void Update()
{
this.Get().Update();
}
}
public static class NetInnerSystem
{
public static void Awake(this NetInnerComponent self)
{
self.Awake(NetworkProtocol.TCP);
self.MessagePacker = new MongoPacker();
self.MessageDispatcher = new InnerMessageDispatcher();
}
public static void Awake(this NetInnerComponent self, string host, int port)
{
self.Awake(NetworkProtocol.TCP, host, port);
self.MessagePacker = new MongoPacker();
self.MessageDispatcher = new InnerMessageDispatcher();
}
public static void Update(this NetInnerComponent self)
{
self.Update();
}
}
}
\ No newline at end of file
using Model;
namespace Hotfix
{
[ObjectEvent]
public class NetOuterComponentEvent : ObjectEvent<NetOuterComponent>, IAwake, IAwake<string, int>, IUpdate
{
public void Awake()
{
this.Get().Awake();
}
public void Awake(string a, int b)
{
this.Get().Awake(a, b);
}
public void Update()
{
this.Get().Update();
}
}
public static class NetOuterSystem
{
public static void Awake(this NetOuterComponent self)
{
self.Awake(NetworkProtocol.TCP);
self.MessagePacker = new MongoPacker();
self.MessageDispatcher = new OuterMessageDispatcher();
}
public static void Awake(this NetOuterComponent self, string host, int port)
{
self.Awake(NetworkProtocol.TCP, host, port);
self.MessagePacker = new MongoPacker();
self.MessageDispatcher = new OuterMessageDispatcher();
}
public static void Update(this NetOuterComponent self)
{
self.Update();
}
}
}
\ No newline at end of file
......@@ -11,7 +11,7 @@ namespace Hotfix
}
}
public static class RealmGateAddressComponentE
public static class RealmGateAddressSystem
{
public static void Start(this RealmGateAddressComponent component)
{
......
using Model;
namespace Hotfix
{
[ObjectEvent]
public class ServerFrameComponentEvent : ObjectEvent<ServerFrameComponent>, IAwake
{
public void Awake()
{
this.Get().Awake();
}
}
public static class ServerFrameSystem
{
public static void Awake(this ServerFrameComponent self)
{
self.Frame = 0;
self.FrameMessage = new FrameMessage() {Frame = self.Frame};
self.UpdateFrameAsync();
}
public static async void UpdateFrameAsync(this ServerFrameComponent self)
{
TimerComponent timerComponent = Game.Scene.GetComponent<TimerComponent>();
while (true)
{
if (self.Id == 0)
{
return;
}
await timerComponent.WaitAsync(40);
MessageHelper.Broadcast(self.FrameMessage);
++self.Frame;
self.FrameMessage = new FrameMessage() { Frame = self.Frame };
}
}
public static void Add(this ServerFrameComponent self, AFrameMessage message)
{
self.FrameMessage.Messages.Add(message);
}
}
}
\ No newline at end of file
......@@ -3,6 +3,7 @@
namespace Model
{
[BsonKnownTypes(typeof(Actor_Test))]
[BsonKnownTypes(typeof(AFrameMessage))]
public abstract class AActorMessage : AMessage
{
}
......@@ -19,6 +20,10 @@ namespace Model
{
}
/// <summary>
/// 帧消息,继承这个类的消息会经过服务端转发
/// </summary>
[BsonKnownTypes(typeof(Frame_ClickMap))]
public abstract class AFrameMessage : AActorMessage
{
public long Id;
......
......@@ -6,40 +6,4 @@ namespace Model
{
Task Handle(Session session, Entity entity, ActorRequest message);
}
/// <summary>
/// gate session 收到的消息直接转发给客户端
/// </summary>
public class GateSessionEntityActorHandler : IEntityActorHandler
{
public async Task Handle(Session session, Entity entity, ActorRequest message)
{
((Session)entity).Send(message.AMessage);
ActorResponse response = new ActorResponse
{
RpcId = message.RpcId
};
session.Reply(response);
}
}
public class CommonEntityActorHandler : IEntityActorHandler
{
public async Task Handle(Session session, Entity entity, ActorRequest message)
{
await Game.Scene.GetComponent<ActorMessageDispatherComponent>().Handle(session, entity, message);
}
}
public class MapUnitEntityActorHandler : IEntityActorHandler
{
public async Task Handle(Session session, Entity entity, ActorRequest message)
{
if (message.AMessage is AFrameMessage aFrameMessage)
{
Game.Scene.GetComponent<ServerFrameComponent>().Add(aFrameMessage);
}
await Game.Scene.GetComponent<ActorMessageDispatherComponent>().Handle(session, entity, message);
}
}
}
\ No newline at end of file
......@@ -9,102 +9,19 @@ namespace Model
public ActorRequest Message;
}
[ObjectEvent]
public class ActorComponentEvent : ObjectEvent<ActorComponent>, IAwake, IAwake<IEntityActorHandler>
{
public void Awake()
{
this.Get().Awake();
}
public void Awake(IEntityActorHandler iEntityActorHandler)
{
this.Get().Awake(iEntityActorHandler);
}
}
/// <summary>
/// 挂上这个组件表示该Entity是一个Actor, 它会将Entity位置注册到Location Server, 接收的消息将会队列处理
/// </summary>
public class ActorComponent: Component
{
private IEntityActorHandler entityActorHandler;
public IEntityActorHandler entityActorHandler;
private long actorId;
public long actorId;
// 队列处理消息
private readonly EQueue<ActorMessageInfo> queue = new EQueue<ActorMessageInfo>();
private TaskCompletionSource<ActorMessageInfo> tcs;
public void Awake()
{
this.entityActorHandler = new CommonEntityActorHandler();
public EQueue<ActorMessageInfo> queue;
this.actorId = this.Entity.Id;
Game.Scene.GetComponent<ActorManagerComponent>().Add(this.Entity);
this.HandleAsync();
}
public void Awake(IEntityActorHandler iEntityActorHandler)
{
this.entityActorHandler = iEntityActorHandler;
this.actorId = this.Entity.Id;
Game.Scene.GetComponent<ActorManagerComponent>().Add(this.Entity);
this.HandleAsync();
}
public async Task AddLocation()
{
await Game.Scene.GetComponent<LocationProxyComponent>().Add(this.actorId);
}
public async Task RemoveLocation()
{
await Game.Scene.GetComponent<LocationProxyComponent>().Remove(this.actorId);
}
public void Add(ActorMessageInfo info)
{
this.queue.Enqueue(info);
if (this.tcs == null)
{
return;
}
var t = this.tcs;
this.tcs = null;
t.SetResult(this.queue.Dequeue());
}
private Task<ActorMessageInfo> GetAsync()
{
if (this.queue.Count > 0)
{
return Task.FromResult(this.queue.Dequeue());
}
this.tcs = new TaskCompletionSource<ActorMessageInfo>();
return this.tcs.Task;
}
private async void HandleAsync()
{
while (true)
{
try
{
ActorMessageInfo info = await this.GetAsync();
await this.entityActorHandler.Handle(info.Session, this.Entity, info.Message);
}
catch (Exception e)
{
Log.Error(e.ToString());
}
}
}
public TaskCompletionSource<ActorMessageInfo> tcs;
public override void Dispose()
{
......
......@@ -2,47 +2,9 @@
namespace Model
{
[ObjectEvent]
public class NetInnerComponentEvent : ObjectEvent<NetInnerComponent>, IAwake, IAwake<string, int>, IUpdate
{
public void Awake()
{
this.Get().Awake();
}
public void Awake(string a, int b)
{
this.Get().Awake(a, b);
}
public void Update()
{
this.Get().Update();
}
}
public class NetInnerComponent: NetworkComponent
{
private readonly Dictionary<string, Session> adressSessions = new Dictionary<string, Session>();
public void Awake()
{
this.Awake(NetworkProtocol.TCP);
this.MessagePacker = new MongoPacker();
this.MessageDispatcher = new InnerMessageDispatcher();
}
public void Awake(string host, int port)
{
this.Awake(NetworkProtocol.TCP, host, port);
this.MessagePacker = new MongoPacker();
this.MessageDispatcher = new InnerMessageDispatcher();
}
public new void Update()
{
base.Update();
}
public readonly Dictionary<string, Session> adressSessions = new Dictionary<string, Session>();
public override void Remove(long id)
{
......
namespace Model
{
[ObjectEvent]
public class NetOuterComponentEvent : ObjectEvent<NetOuterComponent>, IAwake, IAwake<string, int>, IUpdate
{
public void Awake()
{
this.Get().Awake();
}
public void Awake(string a, int b)
{
this.Get().Awake(a, b);
}
public void Update()
{
this.Get().Update();
}
}
public class NetOuterComponent: NetworkComponent
{
public void Awake()
{
this.Awake(NetworkProtocol.TCP);
this.MessagePacker = new MongoPacker();
this.MessageDispatcher = new OuterMessageDispatcher();
}
public void Awake(string host, int port)
{
this.Awake(NetworkProtocol.TCP, host, port);
this.MessagePacker = new MongoPacker();
this.MessageDispatcher = new OuterMessageDispatcher();
}
public new void Update()
{
base.Update();
}
}
}
\ No newline at end of file
namespace Model
{
[ObjectEvent]
public class ServerFrameComponentEvent : ObjectEvent<ServerFrameComponent>, IAwake
{
public void Awake()
{
this.Get().Awake();
}
}
public class ServerFrameComponent: Component
{
public int Frame;
public FrameMessage FrameMessage;
public void Awake()
{
this.Frame = 0;
this.FrameMessage = new FrameMessage() {Frame = this.Frame};
this.UpdateFrameAsync();
}
public async void UpdateFrameAsync()
{
TimerComponent timerComponent = Game.Scene.GetComponent<TimerComponent>();
while (true)
{
if (this.Id == 0)
{
return;
}
await timerComponent.WaitAsync(30);
//MessageHelper.Broadcast(this.FrameMessage);
++this.Frame;
this.FrameMessage = new FrameMessage() { Frame = this.Frame };
}
}
public void Add(AFrameMessage message)
{
this.FrameMessage.Messages.Add(message);
}
}
}
......@@ -208,8 +208,6 @@
<Compile Include="Base\Message\AMActorHandler.cs" />
<Compile Include="Base\Message\ErrorCode.cs" />
<Compile Include="Base\Message\IMActorHandler.cs" />
<Compile Include="Base\Message\OuterMessageDispatcher.cs" />
<Compile Include="Base\Message\InnerMessageDispatcher.cs" />
<Compile Include="Base\Message\IMHandler.cs" />
<Compile Include="Base\Message\ActorMessageAttribute.cs" />
<Compile Include="Base\Message\MessageAttribute.cs" />
......
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 1770158272730698}
m_IsPrefabParent: 1
--- !u!1 &1770158272730698
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4092934652491172}
- component: {fileID: 114471626497006264}
m_Layer: 0
m_Name: UI
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4092934652491172
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1770158272730698}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &114471626497006264
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1770158272730698}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 502d8cafd6a5a0447ab1db9a24cdcb10, type: 3}
m_Name:
m_EditorClassIdentifier:
data:
- key: UILogin
gameObject: {fileID: 1386170326414932, guid: 9f6d9adc6f537764fa0fea29671e77bf,
type: 2}
- key: UILobby
gameObject: {fileID: 1386170326414932, guid: d8d87e53d93e234448658c9a801a9967,
type: 2}
fileFormatVersion: 2
guid: 5b68b797892145f46a5553c74f060976
timeCreated: 1506131440
licenseType: Free
NativeFormatImporter:
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:
namespace Model
using MongoDB.Bson.Serialization.Attributes;
namespace Model
{
public abstract class AActorMessage : AMessage
{
......@@ -12,6 +14,7 @@
{
}
[BsonKnownTypes(typeof(Frame_ClickMap))]
public abstract class AFrameMessage : AActorMessage
{
public long Id;
......
......@@ -17,7 +17,7 @@ namespace Model
// 普通消息或者是Rpc请求消息
if (message is AMessage || message is ARequest)
{
MessageInfo messageInfo = new MessageInfo(opcode, (AMessage)message);
MessageInfo messageInfo = new MessageInfo(opcode, message);
if (opcode < 2000)
{
Game.Scene.GetComponent<CrossComponent>().Run(CrossIdType.MessageDeserializeFinish, messageInfo);
......
using System.Collections.Generic;
namespace Model
namespace Model
{
[ObjectEvent]
public class ClientFrameComponentEvent : ObjectEvent<ClientFrameComponent>, IUpdate
public class ClientFrameComponentEvent : ObjectEvent<ClientFrameComponent>, IStart
{
public void Update()
public void Start()
{
this.Get().Update();
this.Get().Start();
}
}
......@@ -15,31 +13,58 @@ namespace Model
{
public int Frame;
public Queue<FrameMessage> Queue = new Queue<FrameMessage>();
public EQueue<FrameMessage> Queue = new EQueue<FrameMessage>();
public int count = 1;
public int waitTime;
public const int maxWaitTime = 40;
public void Start()
{
UpdateAsync();
}
public void Add(FrameMessage frameMessage)
{
this.Queue.Enqueue(frameMessage);
}
public void Update()
public async void UpdateAsync()
{
int queueCount = this.Queue.Count;
if (queueCount == 0)
{
return;
}
this.count = 1 + (queueCount + 3) / 5;
for (int i = 0; i < this.count; i++)
TimerComponent timerComponent = Game.Scene.GetComponent<TimerComponent>();
while (true)
{
// 如果队列中消息多于4个,则加速跑帧
this.waitTime = maxWaitTime;
if (this.Queue.Count > 4)
{
this.waitTime = maxWaitTime - (this.Queue.Count - 4) * 2;
}
// 最快加速一倍
if (this.waitTime < 20)
{
this.waitTime = 20;
}
await timerComponent.WaitAsync(waitTime);
if (this.Id == 0)
{
return;
}
this.UpdateFrame();
}
}
private void UpdateFrame()
{
if (this.Queue.Count == 0)
{
return;
}
FrameMessage frameMessage = this.Queue.Dequeue();
this.Frame = frameMessage.Frame;
......@@ -49,8 +74,6 @@ namespace Model
ushort opcode = Game.Scene.GetComponent<OpcodeTypeComponent>().GetOpcode(message.GetType());
Game.Scene.GetComponent<MessageDispatherComponent>().Handle(new MessageInfo() { Opcode= opcode, Message = message });
}
Game.Scene.GetComponent<CrossComponent>().Run(CrossIdType.FrameUpdate);
}
}
}
......@@ -11,9 +11,9 @@ namespace Model
private readonly Dictionary<long, Session> sessions = new Dictionary<long, Session>();
public IMessagePacker MessagePacker { get; protected set; }
public IMessagePacker MessagePacker { get; set; }
public IMessageDispatcher MessageDispatcher { get; protected set; }
public IMessageDispatcher MessageDispatcher { get; set; }
public void Awake(NetworkProtocol protocol)
{
......@@ -30,7 +30,7 @@ namespace Model
}
}
protected void Awake(NetworkProtocol protocol, string host, int port)
public void Awake(NetworkProtocol protocol, string host, int port)
{
switch (protocol)
{
......@@ -110,7 +110,7 @@ namespace Model
}
}
protected void Update()
public void Update()
{
if (this.Service == null)
{
......
......@@ -17,6 +17,6 @@
public const ushort Actor_TestResponse = 2003;
public const ushort Actor_TransferRequest = 2004;
public const ushort Actor_TransferResponse = 2005;
public const ushort Actor_ClickMap = 2006;
public const ushort Frame_ClickMap = 2006;
}
}
......@@ -78,14 +78,15 @@ namespace Model
// 服务端发给客户端,每帧一条
[Message(Opcode.FrameMessage)]
public class FrameMessage : AMessage
public class FrameMessage : AActorMessage
{
public int Frame;
public List<AFrameMessage> Messages = new List<AFrameMessage>();
}
[Message(Opcode.Actor_ClickMap)]
public class Actor_ClickMap: AActorMessage
// 客户端点击地图
[Message(Opcode.Frame_ClickMap)]
public class Frame_ClickMap: AFrameMessage
{
}
......
......@@ -11,7 +11,7 @@ namespace Hotfix
{
try
{
GameObject bundleGameObject = scene.ModelScene.GetComponent<ResourcesComponent>().GetAsset<GameObject>("uilogin", "UILobby");
GameObject bundleGameObject = ((GameObject)Resources.Load("UI")).Get<GameObject>("UILobby");
GameObject lobby = UnityEngine.Object.Instantiate(bundleGameObject);
lobby.layer = LayerMask.NameToLayer(LayerNames.UI);
UI ui = new UI(scene, type, null, lobby);
......
......@@ -11,7 +11,7 @@ namespace Hotfix
{
try
{
GameObject bundleGameObject = scene.ModelScene.GetComponent<ResourcesComponent>().GetAsset<GameObject>("uilogin", "UILogin");
GameObject bundleGameObject = ((GameObject)Resources.Load("UI")).Get<GameObject>("UILogin");
GameObject lobby = UnityEngine.Object.Instantiate(bundleGameObject);
lobby.layer = LayerMask.NameToLayer(LayerNames.UI);
UI ui = new UI(scene, type, null, lobby);
......

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.15
MinimumVisualStudioVersion = 10.0.40219.1
# Visual Studio 2017
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity.Plugins", "Unity.Plugins.csproj", "{D1FDB199-0FB7-099D-3771-C6A942E4E326}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Unity", "Unity.csproj", "{CF118143-7E37-744F-BE45-3F55345FEC40}"
......@@ -43,7 +41,4 @@ Global
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {831A2AF4-3FBE-48B2-8E2B-F2D54966AE04}
EndGlobalSection
EndGlobal
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册