1
\$\begingroup\$

I can define several RPCs in unity and I can call them via the networkView component. But it seems that it gets the RPC called regardless where it is defined.

So I was wondering to know how do the scope of RPC works in Unity. Am I able to call whatever RPC in whatever script which share the same networkView? Or is there any other logic behind?

As a corollary: can I define a unique structured file gathering every RPC in my project?

\$\endgroup\$
2
\$\begingroup\$

Unity will invoke the RPC method on ALL methods with that name that appear in any of the game object's components.

Yes, you could do that, I personally wouldn't recommend it. It will add unneeded dependencies in your project, and pretty much destroys the point OOP.

Right now the RPC scope thing is really quite terrible. Imagine if you have an RPC method in a base class called A. Suppose classes B and C inherit from A. Now, if you attach scripts of both B and C to a single game object( not unrealistic ), RPC calls to methods in the base class simply won't work properly.

Fortunately, this seems to be getting fixed: https://www.youtube.com/watch?v=ywbdVTRe-aA

They seem to be sorting out the networking component of Unity. Hopefully we're not waiting too long.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.