3

When I try to import mathematics it throws me an error saying that

'' error CS0234: The type or namespace name 'Mathematics' does not exist in the namespace 'Unity' (are you missing an assembly reference?)''

I tried, Using System.Mathematics, Using Unity.Mathematics I also tried by typing Math instead of Mathematics. Idk why this is throwing an error, I use Notepad++ for scripting.

[1]: https://i.stack.imgur.com/vNs9J.png <--- Error picture

derHugo
  • 83,094
  • 9
  • 75
  • 115
Fame Star
  • 45
  • 1
  • 6
  • Please make sure to use the correct tags. Your code is in `c#` ... `unityscript` is/was a JavaScript flavor like custom language previously used by Unity and is long deprecated by now – derHugo Oct 12 '20 at 13:12

3 Answers3

8

You are just missing the Unity.Mathematics Package.

You will have to add the package using Package Manager -

There are 2 ways you can do this -

Solution 1:

a) Go to Unity and launch Package Manager

b) In the Package Manager, you will find a + Symbol then select "Add package from git URL.."

c) Give this Url in the box: https://github.com/Unity-Technologies/Unity.Mathematics.git?path=src and click on Add

If the above Solution 1 is not working for some reason, you can Manually add it

Solution 2

You will have to download the package locally and then install

Download link: https://github.com/Unity-Technologies/Unity.Mathematics/archive/master.zip

Steps to be followed once you download.

a) Extract the zip file using any zip extractor application (Notably WinRar) and note the location.

b) Next, Go to Unity Package Manager and click on "+" Symbol again, But this time Select

"Add package from disk..."

c) Go to the path where you have extracted the package, yourlocation\Unity.Mathematics-master\Unity.Mathematics-master\src\package.json

Select the package.json and click on open

The package will start installing and then it will import the package automatically into project.

It will take sometime to install, if its fails an error would be displayed in your console stating the installation didn't complete. For me Solution 2 had worked perfectly.

Mike D.
  • 4,034
  • 2
  • 26
  • 41
Suraj Bhandarkar
  • 346
  • 4
  • 11
1

This solved for me:

  • uninstalled all packages and dependencies from current project
  • reinstalled
  • deleted all .csproj and .sln in the root folder of the project
  • In Unity, go to Preferences > External Tools. Click "Regenerate Project Files"

For me, it was clearly a referencing error is VS Code and not a missing package, as Unity was having no problem compiling the code (console was error free). So deleting all csproj and sln files and building them once more should do the trick. Probably items 1 and 2 arent even necessary, but I decided to do a clean install of the dependencies nevertheless.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Caio Castro
  • 521
  • 4
  • 13
  • 1
    Had similar issue, the steps above helped me, but only after **downgrading Visual Studio Code Editor package to version 1.2.3** (it was 1.2.4 originally). – ndry Oct 14 '21 at 20:50
0

I simply uninstalled and reinstalled the Visual Studio Editor from the Package Manager.

Rod G.
  • 1