首页 > 解决方案 > 如何控制 Visual Studio 2019 中哪些花括号链接到哪些?

问题描述

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

    public class SpawnManagerX : MonoBehaviour
    {
    public GameObject[] ballPrefabs;

    private float spawnLimitXLeft = -22;
    private float spawnLimitXRight = 7;
    private float spawnPosY = 30;

    private float startDelay = 1.0f;

    void Start()
    {
    InvokeRepeating("SpawnRandomBall", startDelay, spawnInterval);
    InvokeRepeating("IntervalRandomiser", startDelay, spawnInterval);
    }

    void SpawnRandomBall()
    {
        
    Vector3 spawnPos = new Vector3(Random.Range(spawnLimitXLeft, 
    spawnLimitXRight), spawnPosY, 0);

    Instantiate(ballPrefabs[Random.Range(0, 3)], spawnPos, 
    ballPrefabs[Random.Range(0, 3)].transform.rotation);
    }

    void IntervalRandomiser() {
    public int spawnInterval = Random.Range(3, 6);
    }

我在“ public int spawnInterval = Random.Range(3, 6); ”(倒数第二行)下插入一个新行,并添加一个花括号来关闭 IntervalRandomiser 方法,但花括号会关闭该类。所以,我希望括号关闭 IntervalRandomiser 但它关闭了更大的类。我如何选择括号关闭的方法或类?

标签: visual-studio-2019

解决方案


推荐阅读