【发布时间】:2020-05-26 01:12:48
【问题描述】:
每次我统一按下播放按钮时,它只是坐在那里什么都不做,我认为它与实例化语法有关,这是我的代码,这是我运行的唯一脚本。我正在尝试简单地制作我的游戏对象的网格。如果有人知道为什么那会很棒,或者如果不是,也许您知道更好的方法。谢谢!!
using UnityEngine;
public class Script2 : MonoBehaviour
{
public GameObject Sprite;
void Start()
{
Generate();
}
public void Generate()
{
float width = Sprite.transform.lossyScale.x;
float height = Sprite.transform.lossyScale.y;
for (int y = 0; y <= 100; y += 10)
{
for (int x = 0; x <= 100; y += 10)
{
GameObject Square = Sprite;
Instantiate(Square, new Vector2(x * width, y * height), Quaternion.identity);
}
}
}
}
【问题讨论】:
-
for (int x = 0; x <= 100; y += 10)应该是for (int x = 0; x <= 100; x += 10).. 我怀疑是错字
标签: c# unity3d instantiation