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

Commit c566ad4

Browse files
committed
fixbug
1 parent 23e2225 commit c566ad4

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

Assets/GameFramework/Network/NetworkManager.cs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ public void SetPort(int port)
4848
_kcpService = new KcpService(_port, ReceiveMessage);
4949
}
5050

51-
public Task<IResponse> Call(IRequest message, IPEndPoint endPoint)
51+
public Task<T> Call<T>(IRequest message, IPEndPoint endPoint) where T : class,IResponse
5252
{
53-
var task = new TaskCompletionSource<IResponse>();
53+
var task = new TaskCompletionSource<T>();
5454
message.RpcId = ++_rpcId;
5555
_responseCallback[message.RpcId] = (msg) =>
5656
{
57-
IResponse response = msg as IResponse;
57+
T response = msg as T;
5858
task.SetResult(response);
5959
};
6060
SendMessage(message, endPoint);
@@ -69,10 +69,15 @@ public void SendMessage(object message,IPEndPoint endPoint)
6969
if (attribute.Length <= 0)
7070
throw new GamekException("class not found MessageAttribute");
7171
MessageAttribute mgAttribute = (MessageAttribute)attribute[0];
72+
73+
SendMessage(mgAttribute.TypeCode, messageData, endPoint);
74+
}
7275

73-
_kcpService?.SendMessage(mgAttribute.TypeCode, messageData, endPoint);
76+
public void SendMessage(ushort typeCode, byte[] messageData, IPEndPoint endPoint)
77+
{
78+
_kcpService?.SendMessage(typeCode, messageData, endPoint);
7479
}
75-
80+
7681
public void OnUpdate()
7782
{
7883
_kcpService?.Update();
@@ -100,7 +105,7 @@ private void LoadMessageAttribute()
100105

101106
//get message
102107
attribute = item.GetCustomAttributes(typeof(MessageAttribute), false);
103-
if (attribute.Length > 0 && !item.IsAbstract && item.BaseType == typeof(IMessage))
108+
if (attribute.Length > 0 && !item.IsAbstract)
104109
{
105110
MessageAttribute msAttibute = (MessageAttribute)attribute[0];
106111
_messageCodeType[msAttibute.TypeCode] = item;

Assets/GameFramework/Resource/ResourceManager.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,16 @@ public void LoadAssetAsync<T>(string assetBundleName,string assetName) where T :
132132
_resourceHelper?.LoadAssetAsync<T>(assetBundleName,assetName, LoadAssetAsyncCallback);
133133
}
134134

135+
/// <summary>
136+
/// 卸载资源 主要为卸载AssetBundle
137+
/// </summary>
138+
/// <param name="assetBundleName">资源名称</param>
139+
/// <param name="unload">是否卸载所有资源</param>
140+
public void UnloadAsset(string assetBundleName, bool unload = false)
141+
{
142+
_resourceHelper?.UnloadAsset(assetBundleName, unload);
143+
}
144+
135145
/// <summary>
136146
/// 异步加载场景
137147
/// </summary>

0 commit comments

Comments
 (0)