73 lines
2.3 KiB
C#
73 lines
2.3 KiB
C#
|
|
using System.Text;
|
|
using BingoBrain.Core;
|
|
using UnityEngine;
|
|
using UnityEditor;
|
|
using UnityEngine.Events;
|
|
using Object = UnityEngine.Object;
|
|
|
|
namespace BingoBrain.Asset.Editor
|
|
{
|
|
public class BingoseKit : Singleton<BingoseKit>, IBigose
|
|
{
|
|
|
|
private string assetRootPath = "AssetHotFix/";
|
|
|
|
public T GetAsset<T>(string assetUrl, string assetName) where T : Object
|
|
{
|
|
var assetPath = new StringBuilder(AssetPathFormat(assetUrl));
|
|
// var assetFullPath = "";
|
|
|
|
// if (assetName.EndsWith("!a.png"))
|
|
// {
|
|
// //assetFullPath = AssetPathFormat(assetUrl, assetName);
|
|
// }
|
|
// else
|
|
// {
|
|
assetName = assetName.Split(".")[0];
|
|
//}
|
|
|
|
// if (assetFullPath.IsNullOrWhiteSpace())
|
|
// {
|
|
// // Debug.LogError($"[ Jarvis ] [ AssetDataBaseKit ] 未找到该资源,请确认路径是否正确 [ {assetPath}/{assetName} ] ");
|
|
// }
|
|
var asset = Resources.Load<T>(assetPath.ToString() + "/" + assetName);
|
|
return asset;
|
|
}
|
|
public static T GetAssetstatic<T>(string assetUrl, string assetName) where T : Object
|
|
{
|
|
var assetPath = $"{"AssetHotFix/"}{assetUrl.Replace(".", "/")}";
|
|
assetName = assetName.Split(".")[0];
|
|
var asset = Resources.Load<T>(assetPath.ToString() + "/" + assetName);
|
|
return asset;
|
|
}
|
|
|
|
public void GetAsset<T>(string assetUrl, string assetName, UnityAction<T> onCompleted) where T : Object
|
|
{
|
|
var asset = GetAsset<T>(assetUrl, assetName);
|
|
onCompleted?.Invoke(asset);
|
|
}
|
|
|
|
public void RecycleAsset(string assetUrl, UnityAction onCompleted)
|
|
{
|
|
onCompleted?.Invoke();
|
|
}
|
|
|
|
private string AssetPathFormat(string assetUrl, string assetName)
|
|
{
|
|
var replace = assetUrl.Replace(".", "/");
|
|
var sb = new StringBuilder(replace);
|
|
var folderPath = sb + "/";
|
|
|
|
var assetPath = $"{assetRootPath}{folderPath}{assetName}";
|
|
return assetPath;
|
|
}
|
|
|
|
private string AssetPathFormat(string assetUrl)
|
|
{
|
|
var assetPath = $"{assetRootPath}{assetUrl.Replace(".", "/")}";
|
|
return assetPath;
|
|
}
|
|
}
|
|
}
|