Skip to content

Commit

Permalink
fix: Weaver Generated Cmd/Rpc should be private (#2799)
Browse files Browse the repository at this point in the history
* 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 <info@noobtuts.com>
  • Loading branch information
cxxpxr and miwarnec committed Jun 25, 2021
1 parent 5528bdd commit 74ae04d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Assets/Mirror/Editor/Weaver/Processors/MethodProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 74ae04d

Please sign in to comment.