menu_bookDocumentation
Cheat Sheet: Quick Reference for s&box GameObjects, Components, and Debugging
Quick reference for common s&box operations across debugging, transforms, GameObjects, and Components.
Debugging
| Operation | Code |
|---|---|
| Log to console | Log.Info( $"Hello {username}" ); |
| Draw to screen | DebugOverlay.ScreenText( new Vector2( 50, 50 ), "Hello" ); |
| Assert | Assert.NotNull( obj, "Object was null!" ) |
Transforms
| Operation | Code |
|---|---|
| Get world position | var p = go.WorldPosition; |
| Set world position | go.WorldPosition = new Vector3( 10, 0, 0 ); |
| Get local position | var p = go.LocalPosition; |
GameObjects
| Operation | Code |
|---|---|
| Find by name | Scene.Directory.FindByName( "Cube" ).First(); |
| Find by GUID | Scene.Directory.FindByGuid( guid ); |
| Create | var go = new GameObject(); |
| Delete | go.Destroy() |
| Disable | go.Enabled = false; |
| Duplicate | var newGo = go.Clone(); |
| Add tag | go.Tags.Add( "player" ); |
| Iterate children | foreach( var child in go.Children ) |
| Validity check | if ( go.IsValid() ) |
Components
| Operation | Code |
|---|---|
| Add | var c = go.AddComponent<ModelRenderer>(); |
| Remove | c.Destroy() |
| Disable | c.Enabled = false; |
| Get GameObject | var go = c.GameObject; |
| Get component | var c = go.GetComponent<ModelRenderer>(); |
| Get or add | var c = go.GetOrAddComponent<ModelRenderer>(); |
| Iterate all | foreach ( var c in go.Components.GetAll() ) |
| Get all in scene | foreach ( var c in Scene.GetAll<CameraComponent>() ) |
Was this helpful?