#how do I get C# to export a new type?

5 messages · Page 1 of 1 (latest)

zinc turtle
#

Godot is not recognizing my new C# type...

using Godot;
using System;

[GodotClassName("UIGrid")]
public partial class UIGrid : MarginContainer
{
    private GridContainer Grid;
    private AudioStreamPlayer Player;
    
    [Export] public uint Columns = 0;
    [Export] public AudioStream Sound;
    [Signal] public delegate void ItemFocusEnteredEventHandler(Control item);
    [Signal] public delegate void ItemFocusExitedEventHandler(Control item);
    
    public UIGrid()
    {
        Grid   = new GridContainer();
        Player = new AudioStreamPlayer();
        AddChild(Grid  );
        AddChild(Player);

        ChildEnteredTree += (child) =>
        {
            if (child is Control control)
            {
                control.FocusEntered += _PlaySound;

            }
        };
        ChildExitingTree += (child) =>
        {
            if (child is Control control)
            {
                control.FocusEntered -= _PlaySound;
            }
        };
    }

    public virtual void _PlaySound()
    {
        Player.Stream = Sound;
        Player.Play();
    }
}
orchid grove
zinc turtle
#

sad

zinc turtle
#

@orchid grove wait does this mean exported properties too?

orchid grove
#

I think those should work, but don't quote me on that