【问题标题】:Unity error: CS1513: } expected despite the correct amount of bracketsUnity 错误:CS1513: } 尽管括号的数量正确,但仍是预期的
【发布时间】:2022-07-28 00:41:49
【问题描述】:

这似乎是一个错字,但事实并非如此。如果你仔细观察,你会看到一个私有对象 l;。这样做是因为 != 会导致许多其他错误。之前还好好的,现在就开始不正常了。

private object l;

void Start()
{
    
}

// Update is called once per frame
void Update()
{
  if (Input.GetMouseButtonDown(0))
  {
        RaycastHit hit;
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (Physics.Raycast(ray, out hit))
        {
            BoxCollider bc = hit.collider as BoxCollider;
            if (bc) l = null;) 
            { 
                Destroy(bc.gameObject);
            }
        }
  }  
}

【问题讨论】:

  • if (bc) l = null;) - 这是一个错字。

标签: c# unity3d game-development unityscript


【解决方案1】:
if(bc) l = null;) { }

此块中的错误。 更改。 删除分号。我不确定,但你的陈述应该是这样的。

if(bc == null) {}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-31
    • 2015-06-14
    • 2021-03-25
    • 2021-03-15
    相关资源
    最近更新 更多