Unity 5.5.2f1 to 5.6.1f1 - interpolated strings error?

后端 未结 3 958
逝去的感伤
逝去的感伤 2021-01-12 20:51

I\'ve just updated my Unity version from 5.5.2f1 to 5.6.1f1. Suddenly I get the error:

Feature `interpolated strings\' cannot be used because it is n

相关标签:
3条回答
  • 2021-01-12 21:39

    In Unity 2017 it's now possible to use interpolated strings in Unity if you change the .NET version that Unity uses. Interpolated strings is a feature from C# 6 which is released in .NET 4.6.

    To change to .NET 4.6 go to: Edit > Project Settings > Player, expand "Other settings" and change the "Scripting Runtime Version" to .NET 4.6

    For more info look at: https://docs.unity3d.com/Manual/ScriptingRuntimeUpgrade.html

    In Unity 2018, Unity should use .NET 4.x by default so you should have access to interpolated strings without having to change anything.

    0 讨论(0)
  • 2021-01-12 21:41

    It seems that interpolated strings are still not working after updating. To still use my above mentioned code, I did it the old way.

    Instead of:

    return $"{Timestamp}, {Humidity}, {Temp}, {Light}, {Button}";
    

    I did:

    return string.Format ("{Timestamp}, {Humidity}, {Temp}, {Light}, {Button}", Timestamp, Humidity, Temp, Light, Button);
    
    0 讨论(0)
  • 2021-01-12 21:49

    I have had success using

    string.format("{0},{1},{2},{3}, {4}", Timestamp, Humidity, Temp, Light, Button);
    
    0 讨论(0)
提交回复
热议问题