I'm new learner of Godot Mono and I couldn't understand why _UnhandledInput method does not work. I don't get any error or warnings either.
using Godot;
using System;
public class GameScene : Node2D
{
PackedScene towerPackedScene;
public override void _Ready()
{
towerPackedScene = (PackedScene)GD.Load("res://Tower.tscn");
}
public override void _Process(float delta)
{
}
public override void _UnhandledInput(InputEvent @event)
{
if (@event is InputEventMouseButton mouseButton)
{
GD.Print("clicked"); // does not show message on output
KinematicBody2D tower = (KinematicBody2D)towerPackedScene.Instance();
tower.Position = mouseButton.Position;
this.AddChild(tower);
}
}
}