Creating script templates

    A set of default script templates is provided by default, but it’s also possible to modify existing and create new ones, both per project and the editor.

    There are two places where templates can be managed.

    These are available globally throughout any project. The location of these templates are determined per each OS:

    • Windows: %APPDATA%\Godot\script_templates\
    • Linux: $HOME/.local/share/godot/script_templates/

    The default path to search for templates is the res://script_templates/ directory. The path can be changed by configuring the editor/script_templates_search_path setting in the , both via code and the editor.

    If no script_templates directory is found within a project, it is simply ignored.

    Depending on whether a particular language implements a way to generate scripts out of templates, it’s possible to create a template which can be recognized by that language according to template’s file extension. For GDScript and C#, the extensions must be gd and cs respectively.

    Note

    The built-in editor templates are automatically shadowed by the project-specific templates given both scripts have the same filename.

    The Default template is always generated dynamically per language and cannot be configured nor overridden, but you can use these as the base for creating other templates.

    GDScript

    C#

    1. using Godot;
    2. using System;
    3. {
    4. // Declare member variables here. Examples:
    5. // private int a = 2;
    6. // private string b = "text";
    7. // Called when the node enters the scene tree for the first time.
    8. {
    9. }
    10. // // Called every frame. 'delta' is the elapsed time since the previous frame.
    11. // public override void _Process(float delta)
    12. // {
    13. // }
    14. }

    These are only relevant for GDScript with static typing. Whether these placeholders are actually replaced is determined by the text_editor/completion/add_type_hints setting in the EditorSettings.

    PlaceholderValue
    %INT_TYPE%: int
    %STRING_TYPE%: String
    %FLOAT_TYPE%: float
    -> void