利用脚本组件的public变量
把prefabs拖入到对象相应脚本组件的public变量中,如下图
然后在脚本中写如下代码:
public class explosionScript : MonoBehaviour {
// our ParticleExamples class being turned into an array of things that can be referenced
public ParticleExamples[] particleSystems;
// the gun GameObject
public GameObject gunGameObject;
// a private integer to store the current position in the array