(client) feat:实现热重载,实现多维度,实现武器,实现掉落物,实现状态UI,实现攻击AI (#44)
Co-authored-by: zzdxxz <2079238449@qq.com> Co-committed-by: zzdxxz <2079238449@qq.com>
This commit is contained in:
@ -271,17 +271,17 @@ namespace Configs
|
||||
public static Dictionary<string, T> LoadResources<T>(string path) where T : UnityEngine.Object
|
||||
{
|
||||
// 创建一个字典来存储资源名称和加载好的资源
|
||||
Dictionary<string, T> resourceDict = new Dictionary<string, T>();
|
||||
var resourceDict = new Dictionary<string, T>();
|
||||
|
||||
// 加载指定路径下的所有资源
|
||||
T[] resources = Resources.LoadAll<T>(path);
|
||||
var resources = Resources.LoadAll<T>(path);
|
||||
|
||||
foreach (T resource in resources)
|
||||
foreach (var resource in resources)
|
||||
{
|
||||
if (resource != null)
|
||||
{
|
||||
// 获取资源名称并存入字典
|
||||
string resourceName = resource.name;
|
||||
var resourceName = resource.name;
|
||||
resourceDict[resourceName] = resource;
|
||||
}
|
||||
}
|
||||
@ -314,7 +314,7 @@ namespace Configs
|
||||
try
|
||||
{
|
||||
// 使用 using 自动管理 FileStream 的生命周期
|
||||
using (FileStream fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
|
||||
using (var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
fs.Seek(0, SeekOrigin.Begin); // 将游标移动到文件开头(可选)
|
||||
bytes = new byte[fs.Length]; // 创建一个字节数组来存储文件内容
|
||||
@ -328,10 +328,14 @@ namespace Configs
|
||||
}
|
||||
|
||||
// 创建一个默认大小的 Texture2D 对象
|
||||
Texture2D texture = new Texture2D(2, 2); // 初始大小为 2x2,LoadImage 会自动调整大小
|
||||
var texture = new Texture2D(2, 2, TextureFormat.RGBA32, false); // 初始大小为 2x2,LoadImage 会自动调整大小
|
||||
|
||||
if (texture.LoadImage(bytes)) // 加载图片数据
|
||||
{
|
||||
// 设置过滤模式为 Point (无插值)
|
||||
texture.filterMode = FilterMode.Point;
|
||||
texture.wrapMode = TextureWrapMode.Clamp; // 防止边缘出现意外拉伸
|
||||
|
||||
return texture; // 返回加载成功的 Texture2D 对象
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user