I have to upgrade my C# language version to 7.0 for a project. This is the code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Char : MonoBehaviour {
public float Speed = 5f;
public float SSpeed = 10f;
public float jump = 10f;
public bool gc = false;
public bool GroundTouch = false;
public Text countText;
public Text winText;
private int count;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKey(KeyCode.W) && Input.GetKey(KeyCode.LeftShift))
{
transform.position += Vector3.forward * Time.deltaTime * SSpeed;
}
if (Input.GetKey(KeyCode.A))
{
transform.position += Vector3.left * Speed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.S))
{
transform.position += Vector3.back * Speed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.D))
{
transform.position += Vector3.right * Speed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.Space))
{
transform.position += Vector3.up * jump * Time.deltaTime;
}
Vector3 gc = transform.TransformDirection(Vector3.down);
if (Physics.Raycast (transform.position, gc, .5f))
{
GroundTouch = true;
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Pickup"))
{
other.gameObject.SetActive(false);
count = count + 1;
SetCountText();
}
}
void SetCountText ()
{
countText.text = "Score: " + count.ToString();
if (count >= 7)
{
winText.text = "CONGATULATIONS, YOU WON!";
}
}
}
}
Just reminding you that this is on a Mac computer, and Windows solutions will not work. This is my error message:
Feature 'local functions' is not available in C# 4. Please use language version 7.0 or greater.
Thanks in advance!,I am creating a game with Unity and I get an error saying I have to upgrade C# language version to 7.0. On Windows I see people doing it but on Mac I can't find a way to upgrade the language on a Mac. Please help.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Char : MonoBehaviour {
public float Speed = 5f;
public float SSpeed = 10f;
public float jump = 10f;
public bool gc = false;
public bool GroundTouch = false;
public Text countText;
public Text winText;
private int count;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKey(KeyCode.W) && Input.GetKey(KeyCode.LeftShift))
{
transform.position += Vector3.forward * Time.deltaTime * SSpeed;
}
if (Input.GetKey(KeyCode.A))
{
transform.position += Vector3.left * Speed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.S))
{
transform.position += Vector3.back * Speed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.D))
{
transform.position += Vector3.right * Speed * Time.deltaTime;
}
if (Input.GetKey(KeyCode.Space))
{
transform.position += Vector3.up * jump * Time.deltaTime;
}
Vector3 gc = transform.TransformDirection(Vector3.down);
if (Physics.Raycast (transform.position, gc, .5f))
{
GroundTouch = true;
}
void OnTriggerEnter(Collider other)
{
if (other.gameObject.CompareTag("Pickup"))
{
other.gameObject.SetActive(false);
count = count + 1;
SetCountText();
}
}
void SetCountText ()
{
countText.text = "Score: " + count.ToString();
if (count >= 7)
{
winText.text = "CONGATULATIONS, YOU WON!";
}
}
}
}
My exact error message was Feature 'local functions' is not available in C# 4. Please use language version 7.0 or greater
.Thank you in advance!