From 74ae04d222b51ef990c163bed358f0160bb251cf Mon Sep 17 00:00:00 2001 From: Cooper H <60411087+cxxpxr@users.noreply.github.com> Date: Fri, 25 Jun 2021 13:45:47 -0400 Subject: [PATCH] fix: Weaver Generated Cmd/Rpc should be private (#2799) * Fix for users calling weaver gen'd methods in the inspector Forces the new weaver generated method to be private, preventing prevents users from mistakenly calling weaver generated methods in dropdown menus (such as buttons) in the inspector. * Update Assets/Mirror/Editor/Weaver/Processors/MethodProcessor.cs Co-authored-by: vis2k --- Assets/Mirror/Editor/Weaver/Processors/MethodProcessor.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Assets/Mirror/Editor/Weaver/Processors/MethodProcessor.cs b/Assets/Mirror/Editor/Weaver/Processors/MethodProcessor.cs index 455f9b23f..cd5cd72cf 100644 --- a/Assets/Mirror/Editor/Weaver/Processors/MethodProcessor.cs +++ b/Assets/Mirror/Editor/Weaver/Processors/MethodProcessor.cs @@ -35,6 +35,12 @@ public static MethodDefinition SubstituteMethod(TypeDefinition td, MethodDefinit string newName = RpcPrefix + md.Name; MethodDefinition cmd = new MethodDefinition(newName, md.Attributes, md.ReturnType); + // force new usercode_cmd to be private. + // otherwise the generated User_Cmd could be assigned to UnityEvents in the Inspector + // (User_Cmd() is only called by Invoke_Cmd in this class) + cmd.IsPublic = false; + cmd.IsPrivate = true; + // add parameters foreach (ParameterDefinition pd in md.Parameters) {