728x90
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ResourceManager : MonoBehaviour
{
public T Load<T>(string path) where T : Object
{
return Resources.Load<T>(path);
}
public GameObject Instantiate(string path, Transform parent = null)
{
GameObject prefab = Load<GameObject>($"Prefab/{path}");
if (prefab == null)
{
Debug.Log($"Failed to load prefab : {path}");
return null;
}
return Object.Instantiate(prefab, parent);
}
public void Destroy(GameObject go)
{
if (go == null)
return;
Object.Destroy(go);
}
}
728x90
'기타 기술 > C#' 카테고리의 다른 글
모든 프로젝트의 기본 소스 (0) | 2023.08.22 |
---|---|
NavMeshAgent 기본값 (0) | 2023.08.19 |
Singleton pattern (0) | 2023.08.12 |
NavMeshAgent (0) | 2023.08.11 |
이진 트리로 미로 생성 (0) | 2023.08.11 |