问题遇到的现象和发生背景
Unity中我将脚本挂在一个物体上,无法通过脚本创建物体,如图所示
操作环境、软件版本等信息
Unity2020
尝试过的解决方法
public class GameController : MonoBehaviour
{
private void Start()
{
Initiate();
}
private void Initiate()
{
for (int i = 0; i < 4; i++)
{
for (int c = 0; c < 4; c++)
{
CreateSprite(i,c);
}
}
}
private void CreateSprite(int i,int c)
{
GameObject go = new GameObject();
go.gameObject.AddComponent<Image>();
go.transform.SetParent(this.transform);
}
}
我想要达到的结果
点击运行后,无法创建游戏物体