(client)chore:修改了摄像机的跟踪方式,摄像机控制不再使用单例
This commit is contained in:
@ -296,15 +296,19 @@ namespace Managers
|
||||
var textureWidth = texture.width;
|
||||
var textureHeight = texture.height;
|
||||
|
||||
// 如果不分割(rows和cols都为1),直接创建单个Sprite
|
||||
// 首先创建一个未分割的精灵,使用原始名称
|
||||
if (!sprites.ContainsKey(packId))
|
||||
sprites[packId] = new Dictionary<string, Sprite>();
|
||||
|
||||
// 创建未分割的精灵
|
||||
var fullSpriteRect = new Rect(0, 0, textureWidth, textureHeight);
|
||||
var fullSprite = Sprite.Create(texture, fullSpriteRect, new Vector2(0.5f, 0.5f), pixelsPerUnit);
|
||||
fullSprite.name = baseName; // 使用原始名称
|
||||
sprites[packId][baseName] = fullSprite;
|
||||
|
||||
// 如果不分割(rows和cols都为1),直接返回
|
||||
if (rows == 1 && cols == 1)
|
||||
{
|
||||
if (!sprites.ContainsKey(packId))
|
||||
sprites[packId] = new Dictionary<string, Sprite>();
|
||||
|
||||
var spriteRect = new Rect(0, 0, textureWidth, textureHeight);
|
||||
var sprite = Sprite.Create(texture, spriteRect, new Vector2(0.5f, 0.5f), pixelsPerUnit);
|
||||
sprites[packId][baseName] = sprite;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -316,25 +320,25 @@ namespace Managers
|
||||
Debug.LogError("Texture dimensions are not divisible by the specified rows and columns.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!sprites.ContainsKey(packId))
|
||||
sprites[packId] = new Dictionary<string, Sprite>();
|
||||
|
||||
// 分割纹理并创建多个精灵
|
||||
for (var row = 0; row < rows; row++)
|
||||
{
|
||||
for (var col = 0; col < cols; col++)
|
||||
{
|
||||
Rect spriteRect = new(col * tileWidth, row * tileHeight, tileWidth, tileHeight);
|
||||
var sprite = Sprite.Create(texture, spriteRect, new Vector2(0.5f, 0.5f), pixelsPerUnit);
|
||||
|
||||
var index = (rows - row - 1) * cols + col;
|
||||
|
||||
var index = (rows - row - 1) * cols + col; // 计算索引
|
||||
var spriteName = $"{baseName}_{index}";
|
||||
sprite.name = spriteName;
|
||||
|
||||
// 添加到字典中
|
||||
sprites[packId][spriteName] = sprite;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void Reload()
|
||||
{
|
||||
packagesImages.Clear();
|
||||
|
Reference in New Issue
Block a user