Valid RPC parameters are int, float, string, NetworkPlayer, NetworkViewID, Vector3 and Quaternion. For more information see the RPC section of the manual. You don't need to change the way you call the RPCįunction when you do this. Which will automatically contain the information. To get information on the RPC itelf, you can add a NetworkMessageInfo parameter to the function declaration The communication group set for the network view, with oup, is used for the RPC call. RPC calls are always guaranteed to be executed in the same order as they are sent. Have the same name only one of them is called when RPC is invoked. RPC function names should be unique accross the Scene, if two RPC functions in different scripts If it is just for the RPC function, state synchronization should be turned off and the observed property can be set to none. It doesn't matter if the NetworkView is being used for something else or just for the RPC function. It also provides a mechanism for managing the relationships of computers and their connections to one another. The NetworkView plugin enables the user to examine and manage all signalling and autoconfiguring agents on computer nodes. So, my question is, can I get Unity's NetworkView.RPC method to put it's serialised objects into this "args" parameter? If not, can anyone see anyway around this?īy the way I'm using Vexe's framework, so you might see unusual things like "base.Serializer" etc.The called function must have the tag set ( for C Sharp code).Ī NetworkView must be attached to the GameObject where the RPC function is being called. NetworkView is an open-source program for Windows hosting. Object deserialisedArgs = new object įor( int i = 0 i ( ( string )args ) First we have to deserialise the method arguments. The RPC method: private void ComponentRPCNetwork( params object args ) The only problem now is, Unity won't put the objects it serialises into my params object parameter. I also put the unique component name and method name in the array. NetworkView.RPC( "ComponentRPCNetwork", mode, serialisedObjects ) Serialise arguments and call our RPC method through Unity. So, I now I serialise them IF they're not a NetworkViewID, then send the entire object array to Unity, which it does interpret correctly: protected void ComponentRPC( string methodName, RPCMode mode, params object args ) So, serialising the whole array of objects isn't an option. That's fine, except as far as I can tell, Unity's NetworkView.RPC method is the only thing in the universe that knows how to serialise a NetworkViewID properly. Serialising the entire array results in Unity doing no serialisation in NetworkView.RPC. This method simply serialises the parameters into a string and sends them to unity's RPC method. So, now every RPC call should go through my RPC method. So, to fix this I've added a unique name to every component and have to do some relatively slow searching and reflection in order to have a safe RPC call. This means an arbitrary component will be the "this" of the RPC method that actually gets called. "RPC function names should be unique accross the scene, if two RPC functions in different scripts have the same name only one of them is called when RPC is invoked" This means if I have two components that share a base class that has an RPC method, they won't work due to this: Every component that a game object uses is placed on the object and is disabled/enabled based on it's state machine's current state. Why do I need to do this? The game I'm working on fully conforms to a component style design.
0 Comments
Leave a Reply. |