Search Unity

NativeString Problem

Discussion in 'Entity Component System' started by The-Exceptional-Bruce, Apr 9, 2019.

  1. The-Exceptional-Bruce

    The-Exceptional-Bruce

    Joined:
    May 10, 2015
    Posts:
    29
    I am using a NativeString64 and getting an unexpected result. Anyone know why?

    NativeString64 nativeString = new NativeString64("Testing 1 2 3.");

    Below is the actual results and expected results. XXX is Asian characters that are blocked from being posted.

    Actual Value
    Name Value Type
    nativeString.ToString() "TeXXX" System.String
    nativeString "TeXXX" Unity.Entities.NativeString64

    Expected Value
    Name Value Type
    nativeString.ToString() "Testing 1 2 3." System.String
    nativeString "Testing 1 2 3." Unity.Entities.NativeString64
     
  2. dartriminis

    dartriminis

    Joined:
    Feb 3, 2017
    Posts:
    157
    hmm... are you doing anything between instantiation and reading those values?
     
  3. The-Exceptional-Bruce

    The-Exceptional-Bruce

    Joined:
    May 10, 2015
    Posts:
    29
    No code after instantiation, and trying the NativeString.CopyFrom method gives me the same unexpected result.
     
  4. bryanmcnett

    bryanmcnett

    Unity Technologies

    Joined:
    Aug 16, 2018
    Posts:
    12
    Hello there.

    This is a known bug in all C# debuggers, and does not affect how NativeString64 works at runtime: any struct that contains a
    Code (CSharp):
    1. fixed int[N];
    data member appears in the debugger as one correct integer, followed by N-1 garbage integers. As NativeString64 stores two chars in each integer, the first two chars appear correct, and the rest appear to be garbage.

    The garbage is only a cosmetic problem in the debugger, however, and does not affect your code.

    Thanks, and good luck