reckfellENGINE

A C# script template for Entity

A template creates a source file once; exclude raw templates from project compilation.

On this page

A project template

editor/script/templates_search_path selects the project template directory. For this example use asset://script_templates and script_templates/Entity/counter.cs. Entity is the base type for which this template is offered.

C#
// meta-name: Ready counter
// meta-description: Count readiness calls on an Entity script.
// meta-space-indent: 4
using _BINDINGS_NAMESPACE_;

public partial class _CLASS_ : _BASE_
{
    public int ReadyCalls { get; private set; }

    public override void _Ready()
    {
        ReadyCalls++;
        ReckfellApi.Print("TEMPLATE_READY " + Name);
    }
}

The // meta- lines provide its name, description and indentation size. BINDINGS_NAMESPACE becomes Reckfell, BASE becomes the selected base class and CLASS becomes the created class name. The editor also processes TS as an indentation unit.

Exclude raw templates from compilation

Add this inside Project in the existing .csproj:

XML
<ItemGroup>
  <Compile Remove="script_templates/**/*.cs" />
</ItemGroup>

Otherwise default C# file discovery can include a raw template with unresolved names. .reckfellignore controls editor importing rather than MSBuild Compile items.

Create and check

Open C# script creation for an Entity, enable template use and choose Ready counter. Create GeneratedCounter.cs. After substitution its class must be GeneratedCounter, inherit Entity and include partial.

Rebuild and attach the generated file to an Entity. _Ready prints TEMPLATE_READY followed by the object name and ReadyCalls becomes 1. Changing the template does not update existing scripts.

The substitutions were checked against source, and the resulting file was built and executed. This does not certify an editor-dialog mouse workflow. If the template is missing, check the directory setting, Entity folder, .cs extension and selected language.

partial requirement · Project setup

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.