我试图在Unity中的一组坐标上生成一个预制件,但这个问题总是出现。
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);
}
}发布于 2017-12-05 12:57:04
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);
}
}`它应该可以正常工作,请在互联网上搜索此类错误,然后将其作为问题发布到Stack上,谢谢
https://stackoverflow.com/questions/47613940
复制相似问题