title: Why is NativeArray needed to obtain return values from Unity's Job System?
body: <p>Using the code block below as reference, a single update provides the following results:</p>
  <p><code>intReturn = 0</code></p>
  <p><code>inputArrayReturn = 1</code></p>
  <p><code>internalArrayReturn = 1</code></p>
  <p>The only value that makes sense to me here is <code>internalArrayReturn</code>.</p>
  <p><strong>Why doesn't <code>intReturn</code> equal 1?</strong> What is going on to cause the stuct's value to not change even though during execution it should have had 1 added to it? If it is simply a fundamental difference between NativeArray and int, could someone please explain or point me to a reference that will help me understand this better?</p>
  <p><strong>Also, why doesn't <code>inputArrayReturn</code> equal 0?</strong> <code>NativeArray</code> is a struct, so shouldn't it be treated as a copy of values rather than a reference when the line <code>testArray = testArrayResults</code> executes? If this was the case, then <code>inputArrayReturn</code> would stay equal to 0 rather than being updated to the same value contained in <code>testJob.testArray</code>.</p>
  <pre><code>using UnityEngine;
  using Unity.Jobs;
  using Unity.Collections;
  
  public class ParallelTesting : MonoBehaviour
  {
      void Update()
      {
          NativeArray&lt;int&gt; testArrayResults = new NativeArray&lt;int&gt;(1, Allocator.TempJob);
  
          TestJob testJob = new TestJob
          {
              testInt = 0,
              testArray = testArrayResults
          };
  
          JobHandle testJobHandle = testJob.Schedule();
          testJobHandle.Complete();
  
          int intReturn = testJob.testInt;
          int inputArrayReturn = testArrayResults[0];
          int internalArrayReturn = testJob.testArray[0];
  
          testArrayResults.Dispose();
      }
  
      public struct TestJob : IJob
      {
          public int testInt;
          public NativeArray&lt;int&gt; testArray;
  
          public void Execute()
          {
              testInt += 1;
              testArray[0] = testInt;
          }
      }
  }
  </code></pre>