Fixed spawnable enemies alpha

This commit is contained in:
Marco 2025-09-26 10:53:20 +02:00
commit 6c9222e47e
5 changed files with 252 additions and 162 deletions

View file

@ -5,7 +5,7 @@ namespace Cirno.Scripts.Actors;
[Tool]
public partial class PreviewMarker3D : Marker3D
{
private Texture2D _texture;
protected Texture2D _texture;
protected Texture2D Texture
{
get => _texture;
@ -19,9 +19,9 @@ public partial class PreviewMarker3D : Marker3D
}
}
private bool _fixedSize;
private bool _billboard;
private float _pixelSize = 0.05f;
protected bool _fixedSize;
protected bool _billboard;
protected float _pixelSize = 0.05f;
[Export]
protected bool FixedSize
@ -64,6 +64,21 @@ public partial class PreviewMarker3D : Marker3D
}
}
}
protected float _alpha = 1.0f;
protected float Alpha
{
get => _alpha;
set
{
_alpha = value;
if (Engine.IsEditorHint())
{
QueueRedraw();
}
}
}
[ExportToolButton("Update Icon")] public Callable RedrawButton => Callable.From(Redraw);
[ExportToolButton("Clear Children")] public Callable ClearChildrenButton => Callable.From(ClearChildren);
@ -99,7 +114,7 @@ public partial class PreviewMarker3D : Marker3D
_sprite = null;
}
protected void QueueRedraw()
protected virtual void QueueRedraw()
{
if (!Engine.IsEditorHint()) return;
if (_texture is null) return;
@ -112,12 +127,18 @@ public partial class PreviewMarker3D : Marker3D
//_sprite.Owner = GetTree().EditedSceneRoot;
}
_sprite.Modulate = new Color(_sprite.Modulate.R, _sprite.Modulate.G, _sprite.Modulate.B, Alpha);
_sprite.Texture = _texture;
//_sprite.SetRotationDegrees(new Vector3(-45, 45, 0));
_sprite.FixedSize = FixedSize;
_sprite.SetBillboardMode(Billboard ? BaseMaterial3D.BillboardModeEnum.Enabled : BaseMaterial3D.BillboardModeEnum.Disabled);
_sprite.TextureFilter = BaseMaterial3D.TextureFilterEnum.Nearest;
_sprite.PixelSize = PixelSize;
//GD.Print($"Modulating alpha: {Alpha}");
//_sprite.SetModulate(new Color(_sprite.Modulate.R, _sprite.Modulate.G, _sprite.Modulate.B, Alpha));
}
protected void SetSpriteAlpha(float alpha)
@ -130,7 +151,7 @@ public partial class PreviewMarker3D : Marker3D
}
else
{
GD.Print("Sprite was null");
//GD.Print("Sprite was null");
}
}
}