docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Enum RpcTargetUse

    This parameter configures a performance optimization. This optimization is not valid in all situations.
    Because BaseRpcTarget is a managed type, allocating a new one is expensive, as it puts pressure on the garbage collector.

    Namespace: Unity.Netcode
    Assembly: Unity.Netcode.Runtime.dll
    Syntax
    public enum RpcTargetUse
    Remarks

    When using a Temp allocation type for the RPC target(s):
    You typically don't need to worry about persisting the BaseRpcTarget generated. When using a Persistent allocation type for the RPC target(s):
    You will want to use RpcTarget, which returns BaseRpcTarget, during NetworkBehaviour initialization (i.e. OnNetworkPostSpawn()) and it to a property.
    Then, When invoking the RPC, you would use your BaseRpcTarget which is a persisted allocation of a given set of client identifiers. !! Important !!
    You will want to invoke Dispose() of any persisted properties created via RpcTarget when despawning or destroying the associated NetworkBehaviour component's NetworkObject. Not doing so will result in small memory leaks.

    Fields

    Name Description
    Persistent

    Creates a persisted BaseRpcTarget that does not change and will persist until Dispose() is called.

    Temp

    Creates a temporary BaseRpcTarget used for the frame an RpcAttribute decorated method is invoked.

    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)