No more string interpolation in Unity 5.6.1f1?

Hey guys. I recently updated my Unity version and project from 5.5.2f1 to 5.6.1f1. The compiler now complains about all instances of string interpolation. I’m wondering why this was supported before and no longer supported now, as it was my understanding Unity did not ever support C# 6.0. Let me know if this is a bug and it should be working.

Thanks

Hello, I have the same problem, exactly the same! It seems so weird that it worked before and suddenly not.
I started a topic on stack overflow, but people started telling me that couldn’t have worked before. But it did.

Any suggestions from anyone? Following is my Code and the stack overflow link, so maybe you will a solution there…

http://stackoverflow.com/questions/44107248/unity-5-5-2f1-to-5-6-1f1-interpolated-strings-error

public class SensorData
{
public int Timestamp { get; set; }
public float Humidity { get; set; }
public float Temp { get; set; }
public int Light { get; set; }
public int Button { get; set; }

public override string ToString()
{
return $“{Timestamp}, {Humidity}, {Temp}, {Light}, {Button}”;
}
}

Thanks

1 Like

Hey,

not sure if you manged to use it again/ or were able to rewrite it:

Here how I did it to work again.

Instead of:
return $“{Timestamp}, {Humidity}, {Temp}, {Light}, {Button}”;

I wrote:
return string.Format (“{Timestamp}, {Humidity}, {Temp}, {Light}, {Button}”, Timestamp, Humidity, Temp, Light, Button);

Hope that helped your

Thanks Cruzador, yeah that works, It’s just 5x as ugly :frowning:

Don’t worry Unity 2017.1 solve string interpolation

Here release note Unity 2017.1: 2017.1 released - Industries - News & General Discussion - Unity Discussions
Scripting Runtime experimental upgrade:

  • C#6 and .NET 4.6
  • IL2CPP fully supports the new .NET 4.6 APIs, so you still get the benefits of writing in C# and getting performance of native C++
1 Like