Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

How to Use Span<T> / new C# 7 features in Unity 2019?

Discussion in 'Scripting' started by synchronizer, Jun 23, 2019.

  1. synchronizer

    synchronizer

    Joined:
    Jun 29, 2017
    Posts:
    1
    Hello. I've seen references to being able to use new C# features such as Span<T> in not even the most up-to-date versions of Unity (https://forum.unity.com/threads/burstcompile-span-t-support.603310/). However, System.Memory doesn't seem to exist on my end. I do have ref locals and ref returns, which means that I must have some version of C# 7.

    Looking online, figuring how to use C# 7.2 and 7.3 doesn't seem to be as well-documented as I hoped.
    Would someone help me find the right way to configure Unity and Visual Studio (or maybe I need to install something too?) to support these features?

    I have the 4.x version set in player settings and selected IL2CPP for the backend compiler, for what it's worth. My Unity version is 2019.1.4f1.
    Thanks.

    Edit: Do I still need to use NuGet? I thought that System.Memory would have been fully available as a default library by now.
     
    Last edited: Jun 23, 2019