Search Unity

  1. Want to see 2020.1b in action? Sign up for our Beta 2020.1 Overview Webinar on April 20th for a live presentation from our evangelists and a Q&A session with guests from R&D.
    Dismiss Notice
  2. Interested in giving us feedback? Join our online research interviews on a broad range of topics and share your insights with us.
    Dismiss Notice
  3. We're hosting a webinar for the new Input System where you'll be able to get in touch with the devs. Sign up now and share your questions with us in preparation for the session on April 15.
    Dismiss Notice
  4. Dismiss Notice

NativeString Problem

Discussion in 'Data Oriented Technology Stack' started by The-Exceptional-Bruce, Apr 9, 2019.

  1. The-Exceptional-Bruce

    The-Exceptional-Bruce

    Joined:
    May 10, 2015
    Posts:
    27
    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:
    27
    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:
    11
    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
     
unityunity