docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    C# primitives

    C# primitive types are serialized by built-in serialization code. These types include bool, char, sbyte, byte, short, ushort, int, uint, long, ulong, float, double, and string.

    You can also serialize arrays of C# primitive types, with the exception of arrays of strings (string[]) for performance reasons.

    [Rpc(SendTo.Server)]
    void FooServerRpc(int somenumber, string sometext) { /* ... */ }
    
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.P))
        {
            FooServerRpc(Time.frameCount, "hello, world"); // Client -> Server
        }
    }
    
    In This Article
    Back to top
    Copyright © 2025 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)