Custom child node C#

Godot Version

4.2
im tring to crate a custom node,
with a custom sub node

i tried to this but not luck :\ .
p.s can i make a node abstract (it a base but can’t be instituted )

#if TOOLS
using Godot;
using System;
[Tool]
public partial class ddseed : EditorPlugin
{
    private const string BaseNodeName = "Seed Generator";
    private const string NumberFruitVegetableSeedName = "Number Geo FruitVegetable Seed";
    public override void _EnterTree()
    {
       var baseScript = GD.Load<Script>("res://addons/ddseed/Seeds/SeedGeneratorNode.cs");
       var numberFruitVegetableScript = GD.Load<Script>("res://addons/ddseed/Seeds/NumberRestoreFruitVegetable.cs");
       var textScript = GD.Load<Texture2D>("res://addons/ddseed/Seeds/Seed.png");
       var textScript2 = GD.Load<Texture2D>("res://addons/ddseed/Seeds/Seed.png");
       AddCustomType(BaseNodeName, nameof(Node), baseScript, textScript);
       AddCustomType(NumberFruitVegetableSeedName, nameof(Node), numberFruitVegetableScript, textScript2);
       GD.Print("Custom types added to the editor.");
    }
    public override void _ExitTree()
    {
       RemoveCustomType(BaseNodeName);
       RemoveCustomType(NumberFruitVegetableSeedName);
    }
}
#endif

I don’t work yet with AddCustomType but easy alternative is make you classes GlobalClass.

you can use icons and abstract nodes and you will see abstract class in hierarchy tree when creating node and Of course Godot know you cannot create them :wink:

1 Like

@Moreus is right you have to make your class global [Tool, GlobalClass]. Also you need to remove #if TOOLS if you want your node to also work when game is running. What’s your problem exacly?

2 Likes

thanks king\queen :slight_smile: ,
hope ur day is bright as discord light mode

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.