diff --git a/TestVelGameServer/Assets/RPCTest.cs b/TestVelGameServer/Assets/RPCTest.cs
index d462359..8682283 100644
--- a/TestVelGameServer/Assets/RPCTest.cs
+++ b/TestVelGameServer/Assets/RPCTest.cs
@@ -6,12 +6,6 @@ using VelNet;
public class RPCTest : NetworkComponent
{
- // Start is called before the first frame update
- void Start()
- {
- }
-
- // Update is called once per frame
private void Update()
{
if (Input.GetKeyDown(KeyCode.R))
diff --git a/TestVelGameServer/Packages/VelNetUnity/Runtime/NetworkComponent.cs b/TestVelGameServer/Packages/VelNetUnity/Runtime/NetworkComponent.cs
index 70548e4..80bb3ed 100644
--- a/TestVelGameServer/Packages/VelNetUnity/Runtime/NetworkComponent.cs
+++ b/TestVelGameServer/Packages/VelNetUnity/Runtime/NetworkComponent.cs
@@ -12,6 +12,8 @@ namespace VelNet
protected bool IsMine => networkObject != null && networkObject.owner != null && networkObject.owner.isLocal;
protected VelNetPlayer Owner => networkObject != null ? networkObject.owner : null;
+ private MethodInfo[] methodInfos;
+
///
/// call this in child classes to send a message to other people
///
@@ -41,11 +43,16 @@ namespace VelNet
int length = reader.ReadInt32();
byte[] parameterData = reader.ReadBytes(length);
- MethodInfo[] mInfos = GetType().GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic);
- Array.Sort(mInfos, (m1, m2) => string.Compare(m1.Name, m2.Name, StringComparison.Ordinal));
+
+ if (methodInfos == null)
+ {
+ methodInfos = GetType().GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance | BindingFlags.NonPublic);
+ Array.Sort(methodInfos, (m1, m2) => string.Compare(m1.Name, m2.Name, StringComparison.Ordinal));
+ }
+
try
{
- mInfos[methodIndex].Invoke(this, length > 0 ? new object[] { parameterData } : Array.Empty