- Not thread safe
- There may be minor API changes
-
From the release page or as an archive from the branch. In the
master
branch there is a stable tested version -
git module
https://github.com/Felid-Force-Studios/StaticEcs-Unity.git
in Unity PackageManager or adding it toPackages/manifest.json
The module provides additional integration options with the Unity engine:
A script that adds the option to configure an entity in the Unity editor and automatically create it in the ECS world
Add the StaticEcsEntityProvider
script to an object in the scene:
Usage type
- type of creation, automatically when calling Start() MonoBehaviour or manually
On create type
- action after creation, delete the StaticEcsEntityProvider
component from the object, delete the entire object, or nothing
Wotld
- the type of world in which the entity will be created
Components
- component data
Tags
- entity tags
Masks
- entity masks
A script that adds the ability to configure an event in the Unity editor and automatically send it to the ECS world
Add the StaticEcsEventProvider
script to an object in the scene:
Usage type
- type of creation, automatically when calling Start() MonoBehaviour or manually
On create type
- action after creation, delete the StaticEcsEntityProvider
component from the object, delete the entire object, or nothing
Wotld
- type of world in which the event will be sent
Type
- event type
Class generators are optionally available in the Asset Creation menu Assets/Create/Static ECS/
ECS runtime data monitoring and management window
To connect worlds and systems to the editor window, you must call a special method when initializing the world and systems
specifying the world or systems required
ClientEcs.Create(EcsConfig.Default());
//...
EcsDebug<ClientWorldType>.AddWorld();
//...
ClientEcs.Initialize();
ClientSystems.Create();
//...
EcsDebug<ClientWorldType>.AddSystem<ClientSystemsType>();
//...
ClientSystems.Initialize();
Filter
allows to select the necessary entitiesSelect
allows you to select the columns to displayShow data
allows to select the displayed data in the columnsMax entities result
maximum number of displayed entities
To display component data in a table, you must set the StaticEcsEditorTableValue
attribute in the component to field or property
public struct Position : IComponent {
[StaticEcsEditorTableValue]
public Vector3 Val;
}
To display a different component name, you must set the StaticEcsEditorName
attribute on the component
[StaticEcsEditorName("My velocity")]
public struct Velocity : IComponent {
[StaticEcsEditorTableValue]
public float Val;
}
entity control buttons are also available
- eye icon - open the entity in the viewer
- lock - pin the entity to the top of the table
- trash - destroy the entity from the world
Displays all entity data with the option to modify, add and delete components
Allows customization and creation of a new entity at runtime
Displays all world, component and event data
Displays recent events, their details and the number of subscribers who have unread the event
Events marked in yellow mean they are suppressed
Events marked in gray mean that they have been read by all subscribers
To display these components in a table, you must set the StaticEcsEditorTableValue
attribute in the event for field or property
public struct DamageEvent : IEvent {
public float Val;
[StaticEcsEditorTableValue]
public string ShowData => $"Damage {Val}";
}
Allow the viewing and modification (for unread only) of event data
Allows to configure and create a new event at runtime
Displays all systems in the order in which they are executed
Allows turning systems on and off during runtime
Displays the average execution time of each system
Update per second
- allows to define how many times per second the data of an open tab should be updated
To implement your own editor for a specific type or component, you need in the Editor folder of your project
Create a class that implements IStaticEcsValueDrawer
or IStaticEcsValueDrawer<T>
method DrawValue
displays information on tabs Entity viever
, Event viever
и StaticEcsEntityProvider
, StaticEcsEventProvider
method DrawTableValue
displays information on tabs Entity table
, Event table
Example:
sealed class IntDrawer : IStaticEcsValueDrawer<int> {
protected override bool DrawValue(string label, ref int value) {
var newValue = EditorGUILayout.IntField(label, value);
if (newValue == value) {
return false;
}
value = newValue;
return true;
}
protected override void DrawTableValue(ref int value, GUIStyle style, GUILayoutOption[] layoutOptions) {
EditorGUILayout.SelectableLabel(value.ToString(CultureInfo.InvariantCulture), style, layoutOptions);
}
}