*
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user