Reactivity
A reactive property system for components
thumb_up1upvotes
hard_drive
0 MB
folder
47 files
build
Engine v26
About This Package
sbox-reactivity
A reactivity system for s&box. It makes writing code that runs in response to state changes easy. Check out https://github.com/impulsh/sbox-reactivity for documentation.
public class MyComponent : ReactiveComponent
{
[Property, Reactive]
public float Speed { get; set; } = 50f;
[Reactive, Derived(nameof(_tintColor))]
public Color TintColor { get; } = Color.Blue;
private Color _tintColor()
{
// Calculate the tint color only when the speed changes
return Math.Abs(Speed) <= 100f ? Color.Blue : Color.Red;
}
protected override void OnActivate()
{
Effect(() =>
{
// Create a game object when this component is enabled
var go = new GameObject();
var model = go.AddComponent<ModelRenderer>();
model.Model = Model.Cube;
// Tint the model whenever it changes
Effect(() => model.Tint = TintColor);
// Spin the object every frame while the component is enabled
Frame(() =>
{
var angles = go.LocalRotation.Angles();
angles.yaw += Speed * Time.Delta;
go.LocalRotation = angles;
});
// Destroy the object when the component is disabled
return () => go.Destroy();
});
}
}
1
Total Users
3
Total Sessions
6 min
Total Playtime
Package ID:
igor.reactivity
Created:
2026-02-07 05:34 UTC
Updated:
2026-06-27 21:09 UTC
Type:
library
Public:
Yes
Version:
302096
files:
47
Size:
0.2 MB
Engine Version:
26
Asset Version ID:
302096
Version Created:
2026-06-27 21:09 UTC
Hash:
1782594598
Manifest: Open manifest
Compiler:
Sandbox.Reactivity, SANDBOX, 1701;1702;1591;, , , 1, Debug, Array, Array, Array, Array
Cs Proj Name:
Sandbox.Reactivity
Resources:
Code Package References:
302096
Jun 27, 2026
Fix debug info exception outside of game project
167723
Mar 29, 2026
Fix editor content
167719
Mar 29, 2026
Add infinite loop inspector
166668
Mar 27, 2026
Add reactivity debugger
160359
Mar 8, 2026
Allow ReactiveComponent activation during OnStart
156563
Feb 27, 2026
Fix state mutation in effect not causing re-run
156144
Feb 25, 2026
Support reactivity attributes on static properties
155734
Feb 24, 2026
Add GetEffectCancelToken
154843
Feb 21, 2026
Add Each method
154475
Feb 19, 2026
Add tick/frame methods