CS1519为统一中的C#
我是新的编码,遇到了一个错误的代码,我不知道如何修复它。我正在使用unity 2018,它告诉我- 错误CS1519:类、结构或接口成员声明中的无效标记“=”CS1519为统一中的C#,c#,unity3d,C#,Unity3d,我是新的编码,遇到了一个错误的代码,我不知道如何修复它。我正在使用unity 2018,它告诉我- 错误CS1519:类、结构或接口成员声明中的无效标记“=” using System.Collections; using System.Collections.Generic; using UnityEngine; public class AutoCookies : MonoBehaviour { public bool CreatingCookie = false;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AutoCookies : MonoBehaviour {
public bool CreatingCookie = false;
public static CookieIncrease = 1;
public int InternalIncrease;
void Update() {
InternalIncrease = CookieIncrease;
if (CreatingCookie == false)
{CreatingCookie = true;
StartCoroutine(CreateTheCookie());
}
}
IEnumerator CreateTheCookie ()
{
GlobalCookie.CookieCount += InternalIncrease;
yield return new WaitForSeconds(1);
CreatingCookie = false;
}
}
我已经了解了错误的实际含义,并试图修复它,但没有成功。该代码旨在为我为12年级主要作品编写的游戏自动创建cookies。正如Daniel White所说,
public static CookieIncrease=1代码>是问题所在。
CookieIncrease没有类型定义。
public static int CookieIncrease=1
可能就是您想要的。公共静态CookieIncrease=1代码>缺少一个类型欢迎使用SO!幸运的是,这是@DanielA.White提到的一个非常简单的修复。如果您不熟悉静态变量及其含义,unity提供了一个快速教程,帮助您了解: