(client) feat:彻底完成瓦片地图模块化加载和索引

This commit is contained in:
m0_75251201
2025-07-17 16:02:38 +08:00
parent a4a0f11344
commit e6f9339be2
4 changed files with 90 additions and 141 deletions

View File

@ -31,9 +31,8 @@ namespace Managers
void SplitTextureIntoSprites(string name, Texture2D texture, int rows, int cols, int pixelsPerUnit)
{
if (texture == null || rows <= 0 || cols <= 0)
if (texture == null || rows <= 1 || cols <= 1)
{
Debug.LogError("Invalid parameters for splitting texture.");
return;
}
@ -61,7 +60,7 @@ namespace Managers
// 创建Sprite
var sprite = Sprite.Create(texture, (Rect)spriteRect, new Vector2(0.5f, 0.5f), pixelsPerUnit);
var index = row * cols + col;
var index = (rows-row-1) * cols + col;
sprites[name + $"_{index}"] = sprite;
}
}