인풋매니저, 리소스매니저 구조 생성 및 리소스 정리
This commit is contained in:
30
Assets/Scripts/Managers/ResourceManager.cs
Normal file
30
Assets/Scripts/Managers/ResourceManager.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ResourceManager
|
||||
{
|
||||
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>($"Prefabs/{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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user