Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

NetCode SerializeValue pre0.9 "Can't Serialize using FixedString32Bytes"

Discussion in 'Documentation' started by AnisTKaram, May 18, 2022.

  1. AnisTKaram

    AnisTKaram

    Joined:
    Jul 16, 2020
    Posts:
    6
    I'm trying to save a string as a network variable, but as you know in NetCode, a string is not supported, so we need to Serialize. I saw a video on youtube he did the same thing but it doesn't work for me.
    Here is the error: There is no boxing conversion from "Unity.Collections.FixedString32Bytes" to "System.IConvertible".
    Thank you!

    upload_2022-5-18_22-59-56.png
     
    alinajosephclass likes this.
  2. oivanov

    oivanov

    Joined:
    Apr 22, 2021
    Posts:
    2
  3. AnisTKaram

    AnisTKaram

    Joined:
    Jul 16, 2020
    Posts:
    6
  4. oivanov

    oivanov

    Joined:
    Apr 22, 2021
    Posts:
    2
    Probably you are displaying in the overlay object
    ForceNetworkSerializeByMemcpy<FixedString32Bytes>
    , like:

    Code (CSharp):
    1. private ForceNetworkSerializeByMemcpy<FixedString32Bytes> _info;
    2. overlay.SetText(_info.ToString());
    Try to use
    _info.Value.ToString()
    :
    Code (CSharp):
    1. overlay.SetText(_info.Value.ToString());
     
  5. AnisTKaram

    AnisTKaram

    Joined:
    Jul 16, 2020
    Posts:
    6
    Thanks!