Interfaces - RealityStop/Bolt.Addons.Community GitHub Wiki
Interface Asset
The Interface Asset allows you to define and generate C# interfaces without the need to write C# manually.
It provides an easy-to-use way to design interfaces, their properties, and methods — and have them automatically converted into valid C# code.
Overview
An Interface Asset represents a C# interface (interface) in code generation.
When you create or edit an Interface Asset, the generator will compile your visual representation into a valid C# interface declaration.
Interface Settings
| Field | Description |
|---|---|
| Title | The name of the interface. This becomes the C# interface name. |
| Category | The namespace under which the interface will be placed. |
| Interfaces | A list of other interfaces that this one inherits from. |
Properties
Each Interface Asset can define multiple properties.
Properties correspond to get and/or set members inside the generated interface.
| Field | Description |
|---|---|
| Name | The name of the property. |
| Type | The data type of the property (e.g., int, string, Vector3). |
| Get / Set | Toggles whether the property has a getter and/or setter. |
| (Auto-enabled) | If both Get and Set are disabled, Get will automatically be enabled. |
Methods
Each Interface Asset can also define multiple methods.
Methods represent function signatures within the interface.
| Field | Description |
|---|---|
| Name | The name of the method. |
| Return Type | The type of value returned by the method. |
| Parameters | The list of input parameters the method takes. |
Parameters
Each parameter has its own configuration:
| Field | Description |
|---|---|
| Name | The name of the parameter. |
| Type | The parameter’s data type. |
| Modifier | Optional modifiers (ref, out, etc.). |
| Has Default | Whether the parameter has a default value. |
| Default Value | The default value (if applicable). |
| Attributes | Optional attributes applied to this parameter (e.g., [Range], [Tooltip]). |
Automatic Attributes
If you rename an Interface Asset, the generator automatically adds a
[RenamedFrom("OldInterfaceName")] attribute to preserve type compatibility across versions if it was compiled.
Code Generation Example
Here’s an example of what the generated code might look like:
namespace MyGame.Core
{
[RenamedFrom("IGameEntity")]
public interface IGameEntity
{
}
}
namespace MyGame.Core
{
public interface IPlayerStats : IGameEntity
{
int Health { get; set; }
string Name { get; }
void Reset();
void Heal(int amount);
}
}
Note you have to compile your asset first before before it's type can be used in other assets.