當我撰寫代碼時,我得到一個錯誤,我在第 6 行缺少一個 '}'。當我在那里放了一個 } 時,它告訴我在那里放一個 { 代替。由于我是 Unity 開發的新手,我可能只是愚蠢而沒有看到問題,但如果您需要,這里是完整的錯誤訊息:Assets\Scripts\Difficulty.cs(16,6): error CS1513: } 預期的。這里也是代碼:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Difficulty : MonoBehaviour
{
[SerializeField]
public int difficulty;
[SerializeField]
float time;
float timer = 0;
// Start is called before the first frame update
void Start()
{
public bool updated = false;
float timer = time;
}
// Update is called once per frame
void Update()
{
if (time < 0)
{
updated = true;
difficulty ;
}
}
}
uj5u.com熱心網友回復:
您不能將區域變數宣告為公共變數
void Start()
{
public bool updated = false;
float timer = time;
}
將該public bool...行移動到類范圍內,就像int difficulty是
不太確定下面的行希望做什么,但避免使區域變數與類作用域的變數同名。您已經float timer在類級別宣告了一個,不要在本地方法級別宣告另一個
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/400013.html
標籤:C#
上一篇:將熱源1與冷源2合并
