首页 > 解决方案 > 统一的 C# 的 CS1519

问题描述

我是编码新手,遇到了代码错误,我不确定如何修复它。我正在使用 unity 2018,它告诉我-

错误 CS1519:类、结构或接口成员声明中的标记“=”无效

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 年主要作品编码的游戏自动创建 cookie。

标签: c#unity3d

解决方案


正如丹尼尔怀特所说,public static CookieIncrease = 1;是问题所在。
CookieIncrease 没有类型定义。
public static int CookieIncrease = 1;可能是你想要的。


推荐阅读