

Object's unique identifier (Static object IDs range 1 to 32767. This is useful if you want parts of the object to remain behind (such as buggy Unity 4 cloth). This array will be transferred via RPC and deserialized on the other side. NETs serialization system to serialize any data into a byte array. Arrays arent supportet at all with only one exception: a byte array. This delegate is guaranteed to be called before OnDestroy() notifications get sent out. As i said below, Unity only allows a few types as parameters for an RPC method. If you want to know when this object is getting destroyed, subscribe to this delegate. When set to 'true', it will cause the list of remote function calls to be rebuilt next time they're needed. ID of the channel this TNObject belongs to. More.įindAndExecute (int channelID, uint objID, string funcName, params object parameters)ĭecodeUID (uint uid, out uint objID, out byte rfcID)ĭecode object ID and RFC IDs encoded in a single UINT. It's unlikely that you will need to call this function yourself. More.įindAndExecute (int channelID, uint objID, byte funcID, params object parameters) Retrieve the Tasharen Network Object by ID. Only the object's owner can perform this action. Remove a previously saved remote function call. More.īroadcastToLAN (int port, string rfcName, params object objs) SendQuickly (string rfcName, Player target, params object objs)īroadcastToLAN (int port, byte rfcID, params object objs)

SendQuickly (byte rfcID, Player target, params object objs) SendQuickly (string rfcName, Target target, params object objs) Send a remote function call via UDP (if possible). SendQuickly (byte rfcID, Target target, params object objs) Send (string rfcName, int playerID, params object objs) Send (byte rfcID, int playerID, params object objs) Send (string rfcName, Player target, params object objs) Send (byte rfcID, Player target, params object objs) Send (string rfcName, string targetName, params object objs) Send (string rfcName, Target target, params object objs) Note that you should not use this version of the function if you care about performance (as it's much slower than others), or if players can have duplicate names, as only one of them will actually receive this message. Send (byte rfcID, string targetName, params object objs) Send (byte rfcID, Target target, params object objs) Invoke the function specified by the function name. More.Įxecute (string funcName, params object parameters) More.Įxecute (byte funcID, params object parameters) Register the network object with the lists. More.ĭestroySelf (float delay, bool onlyIfOwner=true) TODO: Add the method calls to a dictionary to reduce bandwidth.Destroy this game object on all connected clients and remove it from the server. It's not the most simple implementation, I know.
UNITY NETWORKVIEW BYTES CODE
Then, you need to tell the code which script it should access via the "terminalScriptName" variable.įor example, if I have two scripts, Server.cs and Client.cs which have both inherited from the above script, then I would have Server.cs to point to "Client" and Client.cs to point to "Server". (NOTE: you do NOT need the RPC tag on functions).įor the settings, you should add the inherited versions of the script to the same Game Object (with a network view, of course). You can then use doRPC to call RPC functions from the inherited script like you would normally. If (maxLength RPC, like so: void ServerRPC(string name, byte data) Protected byte ToByteArray(object value, int maxLength)īyte tempByteArray = new byte īyte lengthBytes = BitConverter.GetBytes((Int32)tempLength) Īrray.Copy(lengthBytes, 0, tempByteArray, 0, 4) Īrray.Copy((byte)value, 0, tempByteArray, 4, tempLength) Įlse if (value.GetType() = typeof(string))īyte rawdata = ((string)value + "\0") GCHandle handle = GCHandle.Alloc(tempBytes, GCHandleType.Pinned) ĭata = (object)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), type) Expected " + tempInfo.Length + " got " + objects.Length) Īrray.Copy(rawValue, index, tempBytes, 0, size) SQDebug.log("RPC function '" + RPCname + "' parameter counts don't match. ParameterInfo tempInfo = tempMethod.GetParameters() SQDebug.log("RPC function does not exist: '" + RPCname + "' in class " + mTerminalScript.GetType()) MethodInfo tempMethod = mTerminalScript.GetType().GetMethod(RPCname, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public) Public byte getRPCBytes(string RPCname, params object objects) NetworkView.RPC(mTerminalRPCName, mode, name, getRPCBytes(name, args))

Protected void doRPC(string name, RPCMode mode, params object args) NetworkView.RPC(mTerminalRPCName, player, name, getRPCBytes(name, args)) Protected void doRPC(string name, NetworkPlayer player, params object args) MTerminalRPCName = terminalScriptName + "RPC" MTerminalScript = (NetCode)GetComponent(terminalScriptName) Okay, I finally got around to making a wrapper class for RPC calls. The RPC works with less total functions, which means it's not a naming error, or anything.
