So I have this piece of code right here written in C#:
using Godot;
using System;
using System.Runtime.CompilerServices;
using System.Threading;
public partial class Buttonparent : Button
{
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
GD.Print("Hello world!");
var button = new Button();
button.Text = "Click me";
button.Pressed += IfButtonPressed;
AddChild(button);
}
private void IfButtonPressed()
{
GD.Print("Hello world!");
}
}
and for some reason it works only when I run the specific scene on it. The scene itself called "zebutton" only has a node called "buttonparent" since it is the parent of the scene (I think? I am pretty new to this.) and it runs perfectly printing out hello world every time I click on it. But I just can't get it to work when I drop in the zebutton.tscn file into the hierarchy of the main scene within the Main parent node. What is wrong?