• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by Simon-O · Feb 04, 2014 at 12:41 AM · c#

Using a Nuget package (Json.Net)

I'm trying to use the Newtonsoft.Json (aka Json.Net) package in Unity.

I can add the package through Nuget in Visual Studio and I see a reference. When I switch back to Unity, I get a

 error CS0103: The name `Newtonsoft' does not exist in the current context

And switching back to VS (and reloading the project) results in no reference.

The author's site states that it's 100% mono-compatible...

Run Anywhere Json.NET supports Windows, Silverlight, Windows Phone, Mono, MonoTouch and MonoDroid.

So I'm wondering if Unity is just incapable of handling Nuget packages? If so, how can I get it to include the assembly? (I can get the DLL but where should I place it for Unity to find it/preserve a reference as appropriate?)

Thanks

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image mrpmorris · Nov 28, 2016 at 10:00 PM 0
Share

Unity.Newtonsoft.Json is the one you need to use. Also, to make sure it works on iOS disable IL2CPP in the player settings

1 Reply

· Add your reply
  • Sort: 
avatar image
5
Best Answer

Answer by Roland1234 · Feb 04, 2014 at 01:26 AM

Yes, Unity itself is incapable of handling Nuget packages, they're more of a VS thing. But as long as the assembly targets .NET 2.0 you should be able to use the .dll in Unity without issue (I think you may have to change the Api Compatibility Level under File\\Build Settings\\Player Settings from .Net 2.0 Subset to the full .Net 2.0 depending on the assembly).

I'm pretty sure this is the version of Newtonsoft's JSON that you'll want to use. I don't remember if a managed assembly needs to be in a specific place, I have mine in Assets\\Plugins but it may not matter. You will likely have to manually add the reference in VS (unless you use UnityVS, which might do it automatically when generating the project).

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image goriloncho · Jul 15, 2014 at 11:39 PM 0
Share

See http://forum.unity3d.com/threads/unity-supports-c-3-5-or-2-0.111440/ for more information about the compability.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

20 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to use TimeScale in Unity? 1 Answer

C# Transform Issues 1 Answer

C# GUI.DrawTexture Tooltip 0 Answers

C# Check If Gameobject is within Collider 1 Answer

Why is not assigning new value ? 1 Answer

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges