I am having issues importing NativeList. It is not able to find the struct. I am able to import NativeArray just fine.
Here are my imports:
using System.Collections.Generic;
using Unity.Jobs;
using Unity.Collections;
using Unity.Burst;
using Unity.Mathematics;
using static Unity.Mathematics.math;
using UnityEngine;
I also noticed that many of the other containers such as NativeQueue, NativeHashmaps, etcs are not there as well. I am using Unity 2019.3.9f1
You have to add the URL manually in the package manager (easier) or edit the manifest file (more error prone).
There’s a good informative video out there:
Also be aware that if you have an assembly set up for your code using NativeList, you will have to reference the Unity.Collections assembly on its list of references. NativeArray, on the other hand, doesn’t need it.
Sure. If you have an assembly defined for the current file (assemblies take whatever is in the same folder or the folders inside it), then click the assembly file in the project view (it is an “.asmdef” file), and in the inspector you will see a section called “Assembly Definition References”. You have to add there the Unity.Collections assembly. If it’s not available that means you haven’t added the Collections package on the Packages Manager window (or whatever the name was before 2019).
This means : In the files inside this assembly I’m using stuff from this OTHER assembly". Then click apply at the end.
Even including a “using Unity.Collections” statement, there is no NativeList or NativeList option currently. I’ve tried all 3 pre-release versions of the Collections package but no NativeList included anymore?
You need to reference the Unity.Collections assembly. This is different than importing the namespace.
You can easily verify that the NativeList file is there, look for this file: Library/PackageCache/com.unity.collections@0.15.0-preview.21/Unity.Collections/NativeList.cs
Thanks Darkgaze, this fixed the situation for me where Visualstudio could not recognize NativeList despite the preview Collections package being shown as loaded and available in the Unity Editor and Package Manager. I did not know where to find and existing Assembly Defintion Reference in the project as I have not used them before, so I created a new empty Assembly Definition References file through Project>Create>Assembly Definition Reference in Unity and only included Unity.Collections in it and that worked.
Entities are NOT needed: your solution works because it will add Collections in addition to a bunch of other packages
If you don’t want to use Entities (but you should someday, very efficient so recommended), just install “Collections” in Package Manager / Unity Registry (select it in the long list, and click on Install (Remove in the screenshot below as mine is already installedon the top-right corner)