Files
MMORPG/Assets/Scripts/Managers/ResourceManager.cs
2026-01-27 00:34:47 +09:00

40 lines
870 B
C#

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;
}
GameObject go = Object.Instantiate(prefab, parent);
int index = go.name.IndexOf("(Clone)");
if (index >= 0)
{
// go.name = go.name.Substring(0, index);
go.name = go.name.Remove(index);
}
return go;
}
public void Destroy(GameObject go)
{
if (go == null)
{
return;
}
Object.Destroy(go);
}
}