sprite usage improvement

This commit is contained in:
Turánszki János
2025-08-01 08:49:42 +02:00
parent ab4dd63ceb
commit 79b4847c8c
+19 -1
View File
@@ -28,7 +28,25 @@ namespace wi
{
if (IsHidden())
return;
wi::image::Draw(GetTexture(), params, cmd);
if ((maskResource.IsValid() && params.maskMap == nullptr) || (backgroundResource.IsValid() && params.backgroundMap == nullptr))
{
// The mask/background resource in sprite is used when it's not specified in params:
// It is mostly a fix for unexpected behaviour in scripts where sprite.SetParams() would overwrite the mask map too
wi::image::Params temp = params;
if (maskResource.IsValid() && params.maskMap == nullptr)
{
temp.setMaskMap(&maskResource.GetTexture());
}
if (backgroundResource.IsValid() && params.backgroundMap == nullptr)
{
temp.setBackgroundMap(&backgroundResource.GetTexture());
}
wi::image::Draw(GetTexture(), temp, cmd);
}
else
{
wi::image::Draw(GetTexture(), params, cmd);
}
}
void Sprite::FixedUpdate()