#RPC calls work as expected in the UnityEditor but not in Build

1 messages · Page 1 of 1 (latest)

meager sierra
#

Hello everyone!

I have a weird issue, I am calling a serverRPC that works in the editor but not in the build
I get this error after getting the logs from the VR device

14:24:23.658
Unity
KeyNotFoundException: The given key 'NoButtonInteractable' was not present in the dictionary.
14:24:23.658
Unity
at System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) [0x00000] in <00000000000000000000000000000000>:0
14:24:23.658
Unity
at Unity.Netcode.LocalSendRpcTarget.Send (Unity.Netcode.NetworkBehaviour behaviour, Unity.Netcode.RpcMessage& message, Unity.Netcode.NetworkDelivery delivery, Unity.Netcode.RpcParams rpcParams) [0x00178] in .\Library\PackageCache\com.unity.netcode.gameobjects@851f28323821\Runtime\Messaging\RpcTargets\LocalSendRpcTarget.cs:50
14:24:23.658
Unity
at Unity.Netcode.ServerRpcTarget.Send (Unity.Netcode.NetworkBehaviour behaviour, Unity.Netcode.RpcMessage& message, Unity.Netcode.NetworkDelivery delivery, Unity.Netcode.RpcParams rpcParams) [0x001d5] in .\Library\PackageCache\com.unity.netcode.gameobjects@851f28323821\Runtime\Messaging\RpcTargets\ServerRpcTarget.cs:86
14:24:23.658
Unity
at Unity.Netcode.NetworkBehaviour.__endSendRpc (Unity.Netcode.FastBufferWriter& bufferWriter, System.UInt32 rpcMethodId, Unity.Netcode.RpcParams

NGO version: 2.3.2

What I've checked:
It is a NetworkBehavior
It is on a spawned GameObject

Is there anything I might be overlooking?
Thank you for your help!

eager vine
#

Are you destroying any components on the GameObject? When and where in your script is the RPC being called?

meager sierra
#

I am not destroying any components on the GameObject 🤔

This is the code, Press gets called externally when I press the trigger button on my VR controller

    public void Press()
    {
        if (_hasBeenInteracted || !IsEnabled)
            return;
        PhoenixLoggerService.Log($"Button pressed clientside by ID:{NetworkManager.LocalClientId}");
        Press_ServerRPC();
    }

    [Rpc(SendTo.Server, RequireOwnership = false)]
    private void Press_ServerRPC(RpcParams rpcParams = default)
    {
        PhoenixLoggerService.Log($"Press_ServerRPC called by ID:{rpcParams.Receive.SenderClientId}");
        Press_ClientRPC();
    }

    [Rpc(SendTo.ClientsAndHost, RequireOwnership = false)]
    private void Press_ClientRPC()
    {
        PhoenixLoggerService.Log($"Press_ClientRPC called by server");
        _audioSource.PlayOneShot(_buttonsPressedSound);
        _pressableButtonObj.transform.position = _startPos + (transform.forward * _pushedInAmount);

        _hasBeenInteracted = true;
        invokeEvent();
    }
#

when the Press_ServerRPC(); get's called that's when the error occurs

flat mountain
#

What is NoButtonInteractable? It seems to be disabled on the server

meager sierra
#

It is the script from where the code is, where do you see it might be disabled on the server?

flat mountain
#

When it's key is not present in the dictionary for RPC targets, it's either disabled or destroyed

meager sierra
#

Ahh like that, I am pretty sure it's not disabled nor destroyed.
Could it be code stripping getting rid of the function by accident in the build?

flat mountain
meager sierra
#

sadly for the Oculus Quest 3 code stripping is something I cannot get rid off

flat mountain
#

Weird. i never had that problem on my quest

meager sierra
#

It is because the MetaXR SDK starts complaining that IL2CPP is not being used for a 64 bit build.
For that you cannot get rid of code stripping (not my expertise so I could be completely wrong 😅 )

#

Then again, it might be far fetched that the RPC function is being stripped away 😅

flat mountain
#

no that won't effect RPCs at all

meager sierra
#

Sad to say I didn't find the root cause but I did use a workaround,
I have written a seperate script that is on a different networkObject which only manages the RPC calls and does nothing else,
the original script calls this "neworking bridge" script and everything functions.

I presume that somehow, somewhere in the project something happened to the networkObject only during a build that messed up the RPC calling on the side of the server.

A mistery unsolved 😅
but atleast I've found a way around it.