Is it possible to use C++ with Unity instead of C#?

  • The title kind of says it all. Is it possible to replace C# with C++ on a game using Unity?

    It is if you have the Pro edition. For more information see: http://docs.unity3d.com/Manual/Plugins.html

  • MLM

    MLM Correct answer

    6 years ago

    It is possible to use C++ with the Free version of Unity, although it is easier to work with if you have a Unity Pro license. All you have to do is wrap it up in a DLL and follow the instructions below on where to place it.

    I wrote an article that covers this topic: Unity and DLLs: C# (managed) and C++ (unmanaged)

    For Unity 4 Free:

    • Add unmanaged code to the Unity Project Root: UnityProject
    • Add managed code to the Plugins folder: UnityProject->Plugins
    • When you build a project, copy the unmanaged code to BuildRoot->Data->Plugins

    For Unity 4 Pro and any Unity 5:

    • Just copy the DLLs into UnityProject->Plugins

    Unmanaged means C++ and Managed means C#

    Has this changed for Unity 5 where the free version contains all of the engine features of the pro version?

    @GeekyMonkey Updated the article and answer.

    It makes no sense to try to replace C# with C++ in the Unity3D context. This answer may be helpful if interfacing with native code was asked for.

    With the new IL2C++ technology, there aren't many reasons to use C++ instead of C#. Right now, it's limited to mobile platforms but expect the tech to soon be available on PC.

    In the linked article, there is a comment near the start: "This guide really only applies to Unity 5- (Unity 4)". Reading the text directly before that comment, I might have thought to read: "This guide really only applies to Unity 5". Does anyone understand that comment?

    @user2023370 I updated that part to make the language clearer "Unity 4 and below", thanks for the comment :)

License under CC-BY-SA with attribution


Content dated before 6/26/2020 9:53 AM