28 lines
631 B
C#
28 lines
631 B
C#
using UnityEngine;
|
|
|
|
public class PlayerSpawnController : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private GameObject _player;
|
|
[SerializeField]
|
|
private GameObject _playerPrefab;
|
|
[SerializeField]
|
|
private GameObject _spawnLocation;
|
|
|
|
void Awake()
|
|
{
|
|
if (GameObject.FindGameObjectWithTag("Player") != null)
|
|
{
|
|
_player = GameObject.FindGameObjectWithTag("Player");
|
|
_player.transform.position = _spawnLocation.transform.position;
|
|
|
|
}
|
|
else
|
|
{
|
|
_player = Instantiate(_playerPrefab);
|
|
_player.transform.position = _spawnLocation.transform.position;
|
|
DontDestroyOnLoad(_player);
|
|
}
|
|
}
|
|
|
|
} |