33 lines
635 B
C#
33 lines
635 B
C#
using UnityEngine;
|
|
using System.Collections;
|
|
|
|
public interface ISpawner{
|
|
void Respawn ();
|
|
}
|
|
|
|
public class Spawner : MonoBehaviour, ISpawner {
|
|
public bool spawnOnStart = true;
|
|
public GameObject source;
|
|
|
|
// Use this for initialization
|
|
void Start () {
|
|
if (spawnOnStart) {
|
|
Respawn();
|
|
}
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update () {
|
|
|
|
}
|
|
|
|
public void Respawn(){
|
|
GameObject obj = (GameObject)Instantiate (source);
|
|
RespawnNotify notify = obj.AddComponent<RespawnNotify> ();
|
|
notify.spawner = this;
|
|
notify.destroyOnRespawn = true;
|
|
obj.transform.position = transform.position;
|
|
obj.SetActive (true);
|
|
}
|
|
}
|