【问题标题】:GameObject not Spawining游戏对象未生成
【发布时间】:2016-08-31 05:56:24
【问题描述】:

我正在制作一个统一的俄罗斯方块游戏,但这段代码并没有产生我的俄罗斯方块。我已将我的游戏对象分配给 group[] 数组。

这是我的代码:

using UnityEngine;
using System.Collections;

public class Spawner1 : MonoBehaviour {

    public GameObject[] group;
    void start(){
        SpawnNext ();
    }
    void SpawnNext(){
        Instantiate(group[Random.Range(0,group.Length)],new Vector2(5.0f,10.0f),Quaternion.identity);
    }
}

【问题讨论】:

  • 对于明显拼写错误的问题,请在 Off Topic > Typo/Not Reproducible 的原因下投票关闭。

标签: c# unity3d unity5


【解决方案1】:

它没有生成,因为您在 start 中使用了小写的 s。这应该是Start 而不是start。请解决这个问题,您的对象现在应该开始生成了。

public class Spawner1 : MonoBehaviour {

    public GameObject[] group;
    void Start(){
        SpawnNext ();
    }

    void SpawnNext(){
        Instantiate(group[Random.Range(0,group.Length)],new Vector2(5.0f,10.0f),Quaternion.identity);
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-27
    • 2017-02-12
    • 1970-01-01
    • 1970-01-01
    • 2021-02-06
    相关资源
    最近更新 更多