繁体   English   中英

大括号未正确连接

[英]Curly brackets not connecting properly

这是我的代码。 尝试重新粘贴代码。 还有很多其他的事情,比如再次编写 function。

当我制作新的 function 时,括号不会连接(在代码的开头和结尾)。 新 function 的右括号将跳转到总结整个代码的那个。 即使正确放置它也无济于事。 提前致谢。

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Shooter : MonoBehaviour
{
    [SerializeField] GameObject projectile;
    [SerializeField] Transform gunPos;
    public void Fire()
    {
        if (!gunPos) { return; }
        GameObject projectileInstance = Instantiate(projectile, gunPos.transform.position, Quaternion.identity) as GameObject;
    }

    private void SetLaneSpawner()
    {
        public AttackerSpawner[] spawners = FindObjectsOfType<AttackerSpawner>();
    }

    private void Start()
    {
        SetLaneSpawner();
    }

    public void Update()
    {
        if (null)
        {
            Debug.Log("pew pew");
            //TODO attack animation
        }
        else
        {
            Debug.Log("wait");
            //TODO idle animation
        }
    }  


}

错误在该行中:

public AttackerSpawner[] spawners = FindObjectsOfType<AttackerSpawner>();

// Remove the public so it becomes.

AttackerSpawner[] spawners = FindObjectsOfType<AttackerSpawner>();

可访问性修饰符(公共、私有等)只能在 class 和属性级别应用。 您不能在 function 中使用它们。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM