47 lines
1.1 KiB
C#
47 lines
1.1 KiB
C#
using CaoCao.Runtime;
|
|
using CaoCao.XAsset;
|
|
using System;
|
|
using UnityEngine;
|
|
|
|
namespace Game
|
|
{
|
|
public class ResourcesComponent : GameComponent
|
|
{
|
|
public string m_ServerAddress;
|
|
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
}
|
|
|
|
public T Load<T>(string path) where T : UnityEngine.Object
|
|
{
|
|
var request = Asset.Load(path, typeof(T));
|
|
if (request == null)
|
|
{
|
|
Log.Warning($"Resource.Load is failed. path = {path}");
|
|
return null;
|
|
}
|
|
|
|
return request.asset as T;
|
|
}
|
|
|
|
|
|
public GameObject Clone(string path, Transform t = null)
|
|
{
|
|
|
|
var request = Asset.InstantiateAsync(path, t);
|
|
if (request == null)
|
|
{
|
|
Debug.LogError("request == null. path:" + path + ", t is null:" + (t == null));
|
|
return null;
|
|
}
|
|
|
|
request.WaitForCompletion();
|
|
return request.gameObject;
|
|
}
|
|
}
|
|
}
|
|
|