2025-04-26 21:05:13 +08:00
|
|
|
|
using UnityEngine;
|
2025-07-02 10:24:01 +08:00
|
|
|
|
using YooAsset;
|
2025-04-26 21:05:13 +08:00
|
|
|
|
|
|
|
|
|
namespace HK
|
|
|
|
|
{
|
|
|
|
|
public interface IResourceManager
|
|
|
|
|
{
|
|
|
|
|
T Load<T>(string assetPath) where T : Object;
|
|
|
|
|
GameObject LoadGameObject(string assetPath);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal class ResourcesManager : ManagerBase<ResourcesManager>, IResourceManager
|
|
|
|
|
{
|
|
|
|
|
public T Load<T>(string assetPath) where T : Object
|
|
|
|
|
{
|
2025-07-02 10:24:01 +08:00
|
|
|
|
var o = YooAssets.LoadAssetSync<T>(assetPath).AssetObject as T;
|
2025-04-26 21:05:13 +08:00
|
|
|
|
return o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public GameObject LoadGameObject(string assetPath)
|
|
|
|
|
{
|
2025-07-02 10:24:01 +08:00
|
|
|
|
var o = Load<GameObject>(assetPath);
|
|
|
|
|
var gameObject = GameObject.Instantiate(o,null);
|
|
|
|
|
return gameObject;
|
2025-04-26 21:05:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2025-07-02 10:24:01 +08:00
|
|
|
|
public GameObject LoadGameObject(string assetPath,Transform parent)
|
2025-04-26 21:05:13 +08:00
|
|
|
|
{
|
2025-07-02 10:24:01 +08:00
|
|
|
|
var gameObject = LoadGameObject(assetPath);
|
|
|
|
|
gameObject.transform.SetParent(parent);
|
2025-04-26 21:05:13 +08:00
|
|
|
|
return gameObject;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|