'Spawning.SpawnCube'是一个'字段',但'方法组'被期望

我想在Unity中产生一组坐标的预制,但是这种情况不断出现。'Spawning.SpawnCube'是一个'字段',但'方法组'被期望

using System.Collections; 

using System.Collections.Generic;

using UnityEngine;

public class Spawning : MonoBehaviour {

public GameObject TestCube;

public GameObject SpawnCube;

public float CubeFallTime = 7.0f;

public Vector3 Pos;

void Start()

{

StartCoroutine(SpawnCube());

}

IEnumerator Spawn()

{

yield return new WaitForSeconds(CubeFallTime);

Instantiate(TestCube, new Vector3(0, 6, 0), Quaternion.identity);

}

}

回答:

SpawnCube是一个变量,而您试图访问它作为一种方法就是为什么误差保持未来

你应该做这样的事情

using System.Collections; 

using System.Collections.Generic;

using UnityEngine;

public class Spawning : MonoBehaviour {

public GameObject TestCube;

public GameObject SpawnCube;

public float CubeFallTime = 7.0f;

public Vector3 Pos;

void Start()

{

StartCoroutine(Spawn());

}

IEnumerator Spawn()

{

yield return new WaitForSeconds(CubeFallTime);

Instantiate(TestCube, new Vector3(0, 6, 0), Quaternion.identity);

}

}`

应该做工精细请搜索互联网这种错误之前发布它作为一个问题在堆栈 谢谢

以上是 'Spawning.SpawnCube'是一个'字段',但'方法组'被期望 的全部内容, 来源链接: utcz.com/qa/258949.html

回到顶部