I have a Job that needs to take some string from main thread and Useuse it Locally within itself locally.
Considering that the Job systemSystem cannot directly accept the Stringstring as an argument, is there any workroundworkaround to circumvent this limit?
Can we move the string to NativeArray anda NativeArray<bytes> and then repackage it back into the string inside the jobsjob and use it?
For now iI just have an empty strig?string as output from Debug.Logthe .Debug.Log below:
string myString = "string";
StringTest job = new StringTest
{
// first iI need a way to copy a string to array of bytes.
inStr = new NativeArray<byte>(myString.Length, Allocator.TempJob),
};
JobHandle handle = joba.Schedule();
handle.Complete();
public struct StringTest : IJob
{
public NativeArray<byte> inStr;
public void Execute(){
string s = Encoding.ASCII.GetString(inStr.ToArray());
Debug.Log("debug log from Job " +s);}
};
}