Unity Job system error: BackingField is not a value type. Job structs may not contain any reference types.
Just started using the Unity Job System.
I'm not really understanding the reference types you can use (if any) in the IJob struct. Vector3 seem to work, so you can use some reference types. I use a List(Vector3[]) and that seems to be giving me trouble.
After trying to schedule my job I get the following error:
InvalidOperationException: GenerateJob.<Rami>k__BackingField is not a value type. Job structs may not contain any reference types.
Unity.Jobs.LowLevel.Unsafe.JobsUtility.CreateJobReflectionData (System.Type type, Unity.Jobs.LowLevel.Unsafe.JobType jobType, System.Object managedJobFunction0, System.Object managedJobFunction1, System.Object managedJobFunction2) (at C:/buildslave/unity/build/Runtime/Jobs/ScriptBindings/Jobs.bindings.cs:96)
Unity.Jobs.IJobExtensions+JobStruct`1[T].Initialize () (at C:/buildslave/unity/build/Runtime/Jobs/Managed/IJob.cs:23)
Unity.Jobs.IJobExtensions.Schedule[T] (T jobData, Unity.Jobs.JobHandle dependsOn) (at C:/buildslave/unity/build/Runtime/Jobs/Managed/IJob.cs:36)
I don't have a clue what "BackingField" is, but it sounds like an unusable reference type, and I didn't explicitly declare a BackingField.
Can someone please explain to me what this error means, and if there is a way to resolve it. Thanks!
Answer by KlayKree · Jul 10, 2019 at 09:54 PM
You can use a Vector3
because its a struct which makes it not a reference type (structs are value types as described here: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/).
I believe you want to use a NativeArray
which can be seen in this example: https://docs.unity3d.com/Manual/JobSystemSchedulingJobs.html,You can use a Vector3
because its a struct which makes it not a reference type. I believe you want to use a NativeArray
, an example may be seen here: https://docs.unity3d.com/Manual/JobSystemSchedulingJobs.html
Your answer
Follow this Question
Related Questions
Im getting an error message CS0117 after adding universal rp please help 0 Answers
Help Troubleshooting: "Cannot generate 9 slice most likely because the size is too big." 2 Answers
Parsing error- Please help! 0 Answers
Error building player because scripts have compile errors in the editor 1 Answer