using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.U2D;
|
using Cysharp.Threading.Tasks;
|
using System.Threading;
|
using ProjSG.Resource;
|
|
public class BuiltInLoader
|
{
|
readonly static string PREFAB_EXTENSION = ".prefab";
|
readonly static string SPRITE_EXTENSION = ".png";
|
readonly static string AUDIO_EXTENSION = ".wav";
|
|
readonly static List<string> excludePngs = new List<string>() { "Launch_1.png", "Launch_2.png", "Launch_3.png", "LoginBackGround.png", "TB_DL_Logo.png" };
|
|
// ...existing code...
|
|
public static async UniTask<Sprite> LoadSpriteAsync(string name, CancellationToken ct = default)
|
{
|
var path = StringUtility.Concat("Assets/ResourcesOut/BuiltIn/Sprites/", name, SPRITE_EXTENSION);
|
return await YooAssetService.Instance.LoadAssetAsync<Sprite>(path, ct: ct);
|
}
|
|
public static async UniTask<GameObject> LoadPrefabAsync(string name, CancellationToken ct = default)
|
{
|
var path = StringUtility.Concat("Assets/ResourcesOut/BuiltIn/Prefabs/", name, PREFAB_EXTENSION);
|
return await YooAssetService.Instance.LoadAssetAsync<GameObject>(path, ct: ct);
|
}
|
|
public static async UniTask<AudioClip> LoadMusicAsync(string name, CancellationToken ct = default)
|
{
|
var path = StringUtility.Concat("Assets/ResourcesOut/BuiltIn/Musics/", name, ".mp3");
|
return await YooAssetService.Instance.LoadAssetAsync<AudioClip>(path, ct: ct);
|
}
|
|
public static async UniTask<AnimationClip> LoadAnimationClipAsync(string name, CancellationToken ct = default)
|
{
|
var path = StringUtility.Concat("Assets/ResourcesOut/BuiltIn/AnimationClips/", name, ".anim");
|
return await YooAssetService.Instance.LoadAssetAsync<AnimationClip>(path, ct: ct);
|
}
|
|
public static async UniTask<Material> LoadMaterialAsync(string name, CancellationToken ct = default)
|
{
|
var path = StringUtility.Concat("Assets/ResourcesOut/BuiltIn/Materials/", name, ".mat");
|
return await YooAssetService.Instance.LoadAssetAsync<Material>(path, ct: ct);
|
}
|
|
public static async UniTask<T> LoadScriptableObjectAsync<T>(string name, CancellationToken ct = default) where T : ScriptableObject
|
{
|
var path = StringUtility.Concat(ResourcesPath.ResourcesOutAssetPath,
|
"BuiltIn/ScriptableObjects/", name, ".asset");
|
return await YooAssetService.Instance.LoadAssetAsync<T>(path, ct: ct);
|
}
|
|
public static async UniTask<Font> LoadFontAsync(string fontName, CancellationToken ct = default)
|
{
|
var path = StringUtility.Concat(ResourcesPath.ResourcesOutAssetPath,
|
"Font/", fontName, ".ttf");
|
return await YooAssetService.Instance.LoadAssetAsync<Font>(path, ct: ct);
|
}
|
|
|
}
|