Search Unity

How can I change C# version from 7.0 to 6.0

Discussion in 'Scripting' started by JianOhZhou, Jun 16, 2018.

  1. JianOhZhou

    JianOhZhou

    Joined:
    Jun 7, 2018
    Posts:
    8
    I'm working on my project with my friends, I use some feature from 7.0 such as tuples but errors occur on my friend's device it said: Feature 'tuples' cannot be used because it is not part of the C# 6.0

    So I want to revert it back to 6.0 because I can't remember all where I used 7.0 syntax
     
  2. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,196
    Something doesn't sound right. What version of Unity are you using? C# 7 Support isn't scheduled until 2018.3, which isn't in beta yet, so I wouldn't think you could possibly be writing C# 7 syntax.

    Sounds more likely that you're using .NET 4.x, and your friend's project is using .NET 3.x. Tuples have existed before C# 7. (C# 7 just adds more funtionality for tuples). For example, this is totally valid under C# 6:

    Code (CSharp):
    1. Tuple<string, string> x = new Tuple<string, string>("","");
    So I'm guessing you're on 4.6, and you need to change it down to 3.5.

    Go to Edit -> Project Settings -> Player, and go to the Other Settings area. Change the Scripting Runtime Version.

    upload_2018-6-15_23-19-29.png
     
    TaleOf4Gamers likes this.
  3. JianOhZhou

    JianOhZhou

    Joined:
    Jun 7, 2018
    Posts:
    8
    I've changes codes to not use tuple, and I also want to use ECS but still have problems like as the image: https://imgur.com/a/VpgLw3t
    So I think I should to something to make it use C# 7.0

    Now using Unity 2018.4.1
     
  4. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    Tuple and ValueTuple are something completely different though.

    There's also the new ValueTuple syntax in c#7.

    And if he's using the incremental compiler package or ECS (which implicitly pulls in the incremental compiler) he might be able to use c#7 syntax.
     
  5. JianOhZhou

    JianOhZhou

    Joined:
    Jun 7, 2018
    Posts:
    8
  6. JianOhZhou

    JianOhZhou

    Joined:
    Jun 7, 2018
    Posts:
    8
    Oh, I will tell my friend to install incremental compiler