For example, I’m creating a library with no dependencies targeting netstandard1.2 in C# 6 (with no dynamic and async) in Visual Studio 2017 RC (outside the Unity). Can Android, iOS, WSA and other platforms use this assembly? What about netstandard1.6, netstandard2.0?
For Unity 5.5, we do not support any version of netstandard. The first support for netstandard will come with the Mono runtime upgrade and .NET 4.6 profile support. I would expect Unity to support netstandard 1.6 at this point, although this is still a bit up in the air.
For Unity 5.5, you’ll need to stick to .NET 3.5 to be safe.
@JoshPeterson I have build a class library with .net standard 1.6 and I am having a hard time to import it with Unity 2017.
// library .csproj file
netstandard1.6
I get an error in Unity: System.Object is defined in an assembly that is not referenced.
I have tried targeting netstandard1.4 as well, but the problem persists.
Any ideas if I should I target the .net4.6 framework directly or if there something else I am missing ?
Please target .NET 4.6 when you use Unity 2017.1. We don’t have support for any version of .Net Standard in Unity yet. We’re working on support for .Net Standard 2.0 (and earlier) versions now. I’m not sure if that will make it into the Unity 2017.2 version, but it is on the way.
@JoshPeterson
Any news about .NET Standard support? Neither 2017.2 nor all following Beta versions tell anything about it in the version infos…would be cool if we could get a state update about the progress…
Support for .NET Standard did not make it into 2017.2. We are actively working on it, and we actually have it mostly complete. We’re working on .csproj generation now, which should be the last step. So we’re still optimistic that we can make it into 2017.3 (although support is not in the betas yet), but we may slip to 2018.1.
I got a chuckle out of microsoft’s description of net standard. Typical “we made a lot of terrible decisions in a hurry, and none of our products work until 2 years later. But we promise this product, which we made in a hurry and is less than a year old, will be different.”
Remember when they decided to make a Window’s version for tablet and PC at the same time, which everyone except them knew was a terrible idea? Before that they were trying a windows version on cell phones (this was before Android.) That’s the stuff net standard is unifying, right?
Their page even mentions Unity3D, I think. It mentions Unity mono, running on 20 platforms (20? really?) as one of the things they want to unify. So somebody at MS might be returning phone calls from Finland.
Once it’s in, will it be mentioned in the patch notes and to use it do we just select it Scripting Runtime Version? Also, what do we gain by targeting Standard 2.0? Future compatibility? Will it be more performant or give us access to something we currently don’t have?
Yes, we will mention the new profile support in the release notes. I don’t think we will ship support for a new profile in a patch release though. It is a pretty big change, so it will likely ship with a full release. The .NET Standard 2.0 support will only be available with the new scripting runtime, so you will need to select that. You will also need to change the Api Compatibility Level setting to be “.NET Standard 2.0”.
The .NET Standard 2.0 profile is much smaller than the .NET 4.6 profile. So you should get smaller build sizes. In addition, we will guarantee that all of the .NET Standard 2.0 API will work on all of our supported platforms. So everything is safe to use.
I don’t think is will provide better runtime performance. Also, .NET Standard 2.0 actually has much less in it than .NET 4.6. In addition, is it a proper subset of .NET 4.6, not adding anything. So we won’t get anything new.
Actually, yes. It will give you access to a lot of high-quality libraries written for .NET Standard in Unity-agnostic way. Currently in general you cannot reliably use third party .NET libraries which was created without Unity in mind, because Unity is so hm… special.
@JoshPeterson thanks for the reply, this sounds very promising!
To make an example: If you want to use high level drivers like the MongoDB .NET driver, it is currentliy not possible to run that build under Linux ( and other operating systems) because this driver is written for native .NET and/or .NET Standard. With Unitys .NET Standard 2.0 compatibility this will get possible over .NET Core which is the first “real” multiplatform SDK for .NET.
just look here for further informations: https://www.microsoft.com/net/core#linuxubuntu
But would anyone using Unity ever want to use MongoDB in it?
It’s a noSQL database. Those aren’t good for storing game data - credit card companies use those to quickly guess whether to flag a transaction. And even so, don’t you run a database on your server, and have Unity run it through the www class?
@Owen-Reynolds You might not want to use MongoDB. But there are a plethora of other libraries that you might find useful and that will now be available to you. In my case, I am eager for this new feature because I will finally be able to write one set of libraries and share them between ALL of the environments I work in. Currently, Unity is the only environment that I have to write custom code for. Now I will be able to write one set of libraries and use them in Asp.Net Core, Xamarin Mobile apps, and Unity. It will be a glorious day when this feature gets released into the wild!
@Owen-Reynolds It’s not about the database actually.
I’m working on a multiplayer project and I decided to use share single code on both client and server. Save me more than half time coding, testing and maintain. Thanks .net4.6 introduced in Unity 2017.x.
But if netstandard2.0 supported.
It will unlock the high performance of .netcore on the server side and left just .net4.6 on Unity.
Are there any details on the new scripting runtime that will support .NET Standard 2.0? Is the plan to ship the new scripting runtime in Unity3D 2018.1? It would be cool to get this plan listed on the .NET Standard page: .NET Standard - .NET | Microsoft Learn