Structs - RealityStop/Bolt.Addons.Community GitHub Wiki
The StructAsset lets you visually design C# structs inside Unity using Visual Scripting.
Structs are lightweight value types ideal for small data containers or configurations.
- Create value types (
struct
) with public or private members. - Define fields, properties, constructors, and methods visually.
- Add interfaces and custom attributes.
- Supports
[Serializable]
,[Inspectable]
,[IncludeInSettings]
, andIDefinedEvent
. - Integrates with FlowGraphs to generate logic for methods, getters, setters, and constructors.

In the Project window:
Create → Visual Scripting → Community → Code → Struct
Setting | Description |
---|---|
Title | The name of the struct (e.g., Vector2D ). |
Category | The namespace where the struct will be placed (e.g., Game.Math ). |
Attributes | Struct-level attributes like [Serializable] or [IncludeInSettings(true)] . |

Option | Description |
---|---|
Serialized | Adds [Serializable] . |
Inspectable | Adds [Inspectable] . |
Include In Settings | Adds [IncludeInSettings(true)] . |
Flag for Defined Event Filtering | Implements IDefinedEvent for Defined Event filtering. |
Interfaces | Interfaces that the struct implements (e.g., IEquatable<T> ). |
Option | Description |
---|---|
Scope | Access modifier (e.g., public ). |
Initializer Type |
None or This (structs cannot call base() ). |
Parameters | Define constructor parameters. |
Body Graph | Optional FlowGraph for constructor logic. |


Example result:
public Vector2D(float x, float y)
{
X = x;
Y = y;
}
Add variables directly to the struct.
Each field can have:
Option | Description |
---|---|
Scope | Access modifier (e.g., public , private ). |
Modifier | Optional modifier like static . |
Name | The field or property name. |
Type | The data type. |
Default Value | Optional default initializer. |
Attributes | Optional field or property attributes. |

Example result:
public float X;
public float Y;
Properties can include getter and setter FlowGraphs, letting you define custom logic visually.
Options include:
Option | Description |
---|---|
Getter / Setter FlowGraphs | Optional logic for custom get/set. |
Getter Scope | Access level for the getter. |
Setter Scope | Access level for the setter. |


Example result:
public float Magnitude
{
get
{
return UnityEngine.Mathf.Sqrt(((X * X) + (Y * Y)));
}
}
Add custom struct methods with parameters, return types, and logic graphs.
Option | Description |
---|---|
Scope | Access modifier. |
Modifier | Optional method modifier. |
Name | The method name. |
Return Type | The return type (e.g., void , int ). |
Parameters | The list of input parameters. |
Body Graph | The FlowGraph used for logic. |
Attributes | Optional method attributes. |
Example result:
public void Normalize()
{
float length = Magnitude;
X = (X / length);
Y = (Y / length);
}
- Implement any info that the struct requires

Graph:

Example result:
public bool Equals(Vector2D other)
{
return (X == other.X && Y == other.Y);
}
Compile your struct using C# Preview or Addons → Compile Selected
.
This generates a valid .cs file that behaves like a standard Unity struct.
#pragma warning disable
using System;
using Unity.VisualScripting;
namespace Game.Math
{
[Serializable]
[IncludeInSettings(true)]
public struct Vector2D : IEquatable<Vector2D>
{
public float X;
public float Y;
public float Magnitude
{
get
{
return UnityEngine.Mathf.Sqrt(((X * X) + (Y * Y)));
}
}
public Vector2D(float x, float y)
{
X = x;
Y = y;
}
public void Normalize()
{
float length = Magnitude;
X = (X / length);
Y = (Y / length);
}
public bool Equals(Vector2D other)
{
return (X == other.X && Y == other.Y);
}
}
}
A new CSharp section appears in the fuzzy finder, giving you units for:
- Asset-defined members (
methods
,properties
,fields
) - The asset type (
typeof(CurrentAssetType)
)