I noticed that anything that is not a nativearray type variable is unaltered even if the job modifies it.
For example.
[BurstCompile]
struct Job : IJob
{
public bool Ran;
void Execute()
{
Ran = true;
}
}
if I ran this job ran would be always be false.
But if i use a nativearray with 1 element it works fine. Is this a known thing with the burst compiler?
Has nothing to do with jobs, burst or native containers.
It’s because jobs are structs and that’s how structs work.
NativeContainers work because they don’t hold values, they hold a pointer.
public void Test()
{
var t = new MyTestStruct();
this.Set(t, 9);
Debug.Log(t.Value); // what is this value
}
private void Set(MyTestStruct test, int val)
{
test.SetValue(val);
}
public struct MyTestStruct
{
public int Value;
public void SetValue(int val)
{
this.Value = val;
}
}