Currently, the scripting backend is IL2CPP. I need to change it to .NET. I am not sure why it is disabled.
I tried to add component via Unity Hub. It doesn't have Add component option and there was no option in Unity Installer as well.
How do I change it to .NET?
You can't
Per the documentation Unity deprecated the .NET backend and only IL2CPP remains.
Note: The .NET scripting backend is deprecated and will be removed in a future release of Unity. We recommend switching to the IL2CPP scripting backend.
Given that that page is for Unity 2018.2 the feature has been removed in Unity 2019, which the current documentation page supports.
L2CPP is the only scripting back end supported for building projects for Universal Windows Platform.
Any other references saying that UWP supports a .NET backend haven't been updated to reflect this change.
See also this Microsoft MR issue on GitHub.
Related
I created a video game with a custom game engine in C# and I recently migrated everything to .NET 6. All of my projects have the TargetFramework "net6.0-windows" or "net6.0" and all works really well for me. However, my players told me, they needed to install .NET 6 SDK on their computers although .NET 6 was already installed. I do not understand where the dependency to the SDK comes from. Is there any settings I need to set that the non-SDK libraries are being used?
I have a few dependencies in my projects which also could lead to the SDK dependency of my game:
gRPC (i.e. Google.Protobuf, Grpc.AspNetCore, Grpc.Net.Client, Grpc.Tools)
Database stuff (System.Data.SQLite)
Logging (log4net)
Some basics (Newtonsoft.Json, System.Drawing.Common, System.Management)
Any tips on how to find the dependency?
What they really need to install (because your application targets net6.0-windows and probably uses Winforms or WPF) is not the SDK, but the ".NET 6.0 desktop runtime". This is a separate download on the .NET download page that is easily overlooked. It's on the right column here, the second heading (".NET Desktop Runtime 6.0.7" is the latest, as of now).
Of course, installing the SDK includes the parts from the desktop runtime, so that works as well, even though it includes more than what the clients would actually need.
I want to be able to call C# code from JavaScript. The mono project used to have a WASM SDK that you could download from their old Jenkins server, but that is no longer public. Existing docs tend to point toward those builds. The Azure Devops builds do not include this SDK. A few messages I've seen on their Github account indicate that they are now focusing on the .NET 6 for WASM. I do not wish to use the Blazor components. Is there a way in .NET 6 to build a minimally sized WASM binary without the Blazor UI?
Yes it's absolutely possible. Blazor does not have a monopoly on C#/WASM and it's far from clear that it's going to wind up being the best long term option (and a lot of evidence it's not).
I recommend starting with the Uno WASM Bootstrap. https://github.com/unoplatform/Uno.Wasm.Bootstrap
2022-06-30 Edit -
More evidence Blazor is not the only game in town nor even at the forefront of innovation here:
https://visualstudiomagazine.com/articles/2022/06/29/uno-platform-4-4.aspx
The Mono WASM SDK is continued in the dotnet/runtime repo. The tooling based on old Packager.exe has evolved into a MSBuild/csproj based solution:
https://github.com/dotnet/runtime/tree/main/src/mono/wasm
samples:
https://github.com/dotnet/runtime/tree/main/src/mono/sample/wasm
The key issue when I trying to use code in a custom project (not within the sample) is that we need to reference a private assembly System.Private.Runtime.InteropServices.JavaScript.dll which is included in Microsoft.NETCore.App.Runtime.browser-wasm. The code is almost the same as WebAssembly.Bindings.dll in old mono wasm sdk.
Here is a screenshot of a WebGL page I created, based on dotnet/runtime/mono/wasm:
BTW there is a viewpoint that the performance of implementing WebGL via calling JavaScript functions from C#, is bad: https://marcoscobena.com/?i=wave-engine-web-performance
NativeAOT-LLVM, an experimental c# compiler not official supported by Microsoft, (https://github.com/dotnet/runtimelab/tree/feature/NativeAOT-LLVM) can also compile C# to Wasm without any UI framework requirements. There's a similar question about libraries at Compiling C# project to WebAssembly
It seems that dotnet 7 has improved WASM support. More information is provided in https://devblogs.microsoft.com/dotnet/dotnet-7-wasm/
I want to reference Windows.Foundation in my Unity project. I have played with with the Scripting Runtime Version and API Compatibility level to no avail. I am using IL2CPP as the scripting backend (since .NET is being deprecated).
Can someone please help me figure out how to get Unity to recognize Windows.Foundation?
I saw this post which seems related but didn't fix it for me.
Missing System.Media.Capture.Frames namespace
It is referenced automatically when you build to Universal Windows Platform. See this: https://docs.unity3d.com/Manual/IL2CPP-WindowsRuntimeSupport.html
Note, you cannot reference .winmd files in the editor as it uses Mono to power scripting, and Mono does not support referencing or calling into Windows Runtime APIs.
Differing from this question, I realise that Unity uses a modified version of .Net 3.5. Thus I revised available options to one of the following:
1- create a TCP server/client to communicate between library and Unity project
2- Use database as messaging system
My question, is there a simpler way I am missing to get my dll to work on Unity?
Note that I just want my Unity project to build for the Universal Windows Platform
I ended up using signalR as a local communication server between my .NET4.5 code and Unity .NET code.
More information in this blog post
I am working on a game using Unity3D version 5. The game should use strict business rules already programmed in a C# .NET4.5 engine. Using Xamarin/Mono, we hope to make this usable on windows, android, others...
I tried building the engine into a dll and use it as a managed plugin in Unity. But Unity uses an old version of Mono to compile the whole game and refuses to use .NET 4.5 dlls.
I really need to use this code, I looked into downgrading it to .NET 3.5 but it is not an acceptable solution given the work already done on the engine.
Concerning android, I think to use Xamarin to get native android code and use it as a native plugin in Unity. Now I need a solution for Windows. I am looking into ways to use the C# code in C++ to make an unmanaged dll but I am struggling understanding which way is applicable here between COM interop, C++/CLI or other methods.
Does any one knows a way to include code from .NET 4.5 in Unity with no/little effort ?
Looks like Unity is upgrading to 4.6+ and is available in beta now
https://forum.unity3d.com/threads/upgraded-mono-net-in-editor-on-5-5-0b4.433541/
Using a visual studio plugin: unmanaged exports, I have been able to export the C# .NET 4.5 to an unmanaged/native dll which I can use in Unity Engine.
This forces to call only simple functions, but with little work, it was possible for me to wrap the core of my engine.
Short answer is no.
Unity has ".NET 2.0/3.5 era functionality," according to an official blog post.
According to the same post, a future version of Unity will be upgraded to "a modern version of .NET," with no timeline given for this major undertaking.
NOTE: This answer was written in response to the original version of the question, which was simply whether the .NET 4.5 library could be used directly in Unity.