Author Topic: private RFC's defined in a base class won't be found by RebuildMethodList()  (Read 2585 times)

andrew

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
This was a frustrating one..  RFC's defined in a base class won't be found by RebuildMethodList() if they are not marked public or protected

So given a class hierarchy like:

public class ObjBase : Monobehaviour { }
public class GameObj : ObjBase { }

For whatever reason type.GetMethods() in TNObject.RebuildMethodList() won't find the following RFC methods if they are defined in ObjBase instead of in GameObj

[RFC] void OnSync( Vector3 _pos ) {
   thisTransform.position = _pos;
}
(or)

[RFC(1)] void OnSync( Vector3 _pos ) {
   thisTransform.position = _pos;
}

the fix is to make them protected...  Not sure if this is a bug in mono or what.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: private RFC's defined in a base class won't be found by RebuildMethodList()
« Reply #1 on: September 25, 2013, 05:26:41 PM »
Just how reflection works. You derived from a class, and inside the derived class you have no access to private functions. Same goes for RFCs.

andrew

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
Re: private RFC's defined in a base class won't be found by RebuildMethodList()
« Reply #2 on: September 25, 2013, 07:51:14 PM »
That said, you can create private RFCs in the derived class and it works okay.  It's a nice "gotcha" to be aware of and hopefully someone having the same problem will run across this post.

TheCodeTraveller

  • Guest
Re: private RFC's defined in a base class won't be found by RebuildMethodList()
« Reply #3 on: September 26, 2013, 01:34:32 AM »
Thanks for the post Andrew, something to keep in mind my side too.