[Solved] Clash with com.unity.jobs and com.unity.collections 1.1.0

When using com.unity.collections version 1.1.0 with A* version 4.3.47 (beta), the following error occurs:

Library\PackageCache\com.unity.jobs@0.7.0-preview.17\Unity.Jobs\IJobParallelForDefer.cs(77,85): error CS8377: The type 'U' must be a non-nullable value type, along with all fields at any level of nesting, in order to use it as parameter 'T' in the generic type or method 'NativeList<T>'

This means A* 4.3.47 can’t be used together with another package that depends on com.unity.collections version 1.1.0 (such as com.unity.netcode.gameobjects version 1.0.0-pre.4).

Manually upgrading to com.unity.jobs version 0.11.0-preview.6 causes some other errors related to unreferenced packages.


Are you saying Unity resolves com.unity.collections to a lower version that is actually required?
Shouldn’t unity automatically use the latest com.unity.collections that is required?

It uses the latest version of the package, but it results in the older version of com.unity.jobs that A* uses to cause the error. The older version of com.unity.collections doesn’t cause the error with com.unity.jobs, but I can’t use the older version because the newer one is a dependency for com.unity.netcode.gameobjects.

You can test this by installing version 1.1.0 of com.unity.collections along with the beta version of A* (when installed using Unity Package Manager).

I don’t think I can do much about it. I want to keep compatibility for people using an older version of the packages too.
However, you can adjust the unity package manager’s resolution mode. See Unity - Manual: Project manifest

Edit: Looks like I was missing a reference to the ALINE assembly. Upgrading to a newer version of the Jobs package was correct, I just hadn’t set up my assembly references correctly

If I upgrade to com.unity.jobs version 0.11.0-preview.6, the error I described earlier disappears, but instead multiple assembly references seem to break and components such as RichAI are no longer recognized as Unity components outside the AstarPathfindingProject assembly. Maybe I’m missing something about using assemblies?

For example, I get this error if I try to access the enabled property of RichAI (among other components):

error CS0012: The type 'VersionedMonoBehaviour' is defined in an assembly that is not referenced. You must add a reference to assembly 'PackageTools, Version=, Culture=neutral, PublicKeyToken=null'.

If I then manually add a reference to the PackageTools assembly, I get the following errors:

The type 'MonoBehaviourGizmos' is defined in an assembly that is not referenced. You must add a reference to assembly 'Drawing, Version=, Culture=neutral, PublicKeyToken=null'.

error CS1061: 'RichAI' does not contain a definition for 'enabled' and no accessible extension method 'enabled' accepting a first argument of type 'RichAI' could be found (are you missing a using directive or an assembly reference?)

There are also warnings like these when trying to get the scripts as components:

info UNT0014: 'RichAI' is not a Unity Component.

info UNT0014: 'RVOController' is not a Unity Component.

So if I understand correctly you managed to solve it?

Yeah, everything seems to be working correctly now. All I had to do was upgrade the Jobs package to its latest version.

After that, it was just a matter of setting up my assembly references correctly, which actually had nothing to do with this issue. It just confused me for a while since I didn’t find clear instructions on how to do it and the errors weren’t pointing at the correct assemblies. This is only an issue if using custom C# assemblies in the Assets folder instead of Unity’s default setup that automatically references all assemblies.