Skip to content

3 ‐ LifeManager

문현우 edited this page Sep 13, 2023 · 2 revisions

📌 LifeManager

🎇 Managed by 조영오

  • 생명력을 관리하는 기능을 담당합니다.

📜 Code Summary

  • Awake()

    • LifeManger 인스턴스를 생성하는 메서드입니다.
  • CreateLife()

    • 새로운 생명력을 생성하는 메서드입니다.
    • lifePrefabs 변수에 저장된 프리펩을 게임 오브젝트로 생성하고, 생명력을 반환합니다.

💻 Code

LifeManager.cs
using UnityEngine;

public class LifeManager : MonoBehaviour
{
    public static LifeManager instance;
    [SerializeField] private GameObject lifePrefabs;

    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
    }

    public GameObject CreateLife(Vector3 lifePos)
    {
        GameObject life = Instantiate(lifePrefabs, lifePos, Quaternion.Euler(0,0,0));
        return life;
    }
}

Clone this wiki locally