Can someone point out the (probably obvious) reason why connecting to a signal is not working in my example? This is my first time trying to connect to a signal in C# and after sleeping on it I'm still not seeing what I'm doing wrong.
When I run the scene this script is in, the line that sets the value of the TextureProgress causes a message to show up in the debugger/errors tab:
E 0:00:01.216 emit_signal: Error calling method from signal 'value_changed': 'TextureProgress(TextureProgress.cs)::OnValueChange': Method not found..
<C++ Source> core/object.cpp:1236 @ emit_signal()
<Stack Trace> :0 @ void Godot.NativeCalls.godot_icall_1_766(IntPtr , IntPtr , Double )()
Range.cs:277 @ void Godot.Range.SetValue(Double )()
Range.cs:104 @ void Godot.Range.set_Value(Double )()
TextureProgress.cs:21 @ void TextureProgress._Ready()()
This is my code - I think it's pretty self explanatory.
using Godot;
using System;
public class TextureProgress : Godot.TextureProgress
{
[Export]
private readonly Texture BarTexture100;
[Export]
private readonly Texture BarTexture75;
[Export]
private readonly Texture BarTexture50;
[Export]
private readonly Texture BarTexture25;
[Export]
private readonly string BarLabelName;
public override void _Ready()
{
this.Connect("value_changed", this, nameof(OnValueChange));
this.Value = 123;
}
public void OnValueChange()
{
var percent = this.Value / this.MaxValue * 100;
if (percent <= 25 && BarTexture25 != null)
{
this.TextureProgress_ = BarTexture25;
}
else if (percent <= 50 && BarTexture50 != null)
{
this.TextureProgress_ = BarTexture50;
}
else if (percent <= 75 && BarTexture75 != null)
{
this.TextureProgress_ = BarTexture75;
}
else if (BarTexture100 != null)
{
this.TextureProgress_ = BarTexture100;
}
this.GetNode<Godot.Label>("../Label").Text = $"{BarLabelName}: {this.Value}/{this.MaxValue}";
}
}