Files
bansonic_beta_main/Assets/scripts/utils/FileUtils.cs
T

26 lines
654 B
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using UnityEngine;
using UnityEngine.UI;
namespace utils
{
public class FileUtils
{
/// <summary>
/// 在unity resource内路径读取Img对象
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public static Sprite getImage(string path)
{
// 从 Resources 加载 Sprite
Sprite sprite = Resources.Load<Sprite>(path);
if (sprite == null)
{
Debug.LogError($"无法在 Resources/{path} 下找到 Sprite");
return null;
}
return sprite;
}
}
}