terminalCode Example

Code Cheat Sheet: Quick Reference for GameObjects, Components, and Transforms

calendar_today May 20, 2026 schedule ~1 min read person PatrickJr verified 50

Quick reference for common s&box operations covering debugging, transforms, GameObjects, and Components. Useful when you know what you want to do but not the exact API call.

Debugging

CSHARP
Log.Info( $"Hello {username}" );                    // Console logging
DebugOverlay.ScreenText( new Vector2( 50, 50 ), "Hello" ); // Screen text
Assert.NotNull( obj, "Object was null!" );          // Assertions

Transforms

CSHARP
var p = go.WorldPosition;                           // Get world position
go.WorldPosition = new Vector3( 10, 0, 0 );        // Set world position
var p = go.LocalPosition;                           // Get local (relative to parent)

GameObjects

CSHARP
Scene.Directory.FindByName( "Cube" ).First();       // Find by name
Scene.Directory.FindByGuid( guid );                 // Find by GUID
var go = new GameObject();                          // Create new
go.Destroy();                                       // Delete
go.Enabled = false;                                 // Disable
var newGo = go.Clone();                             // Duplicate/clone
go.Tags.Add( "player" );                           // Add tag
foreach ( var child in go.Children ) { }            // Iterate children
if ( go.IsValid() ) { }                            // Check not destroyed

Components

CSHARP
var c = go.AddComponent<ModelRenderer>();            // Add component
c.Destroy();                                        // Remove component
c.Enabled = false;                                  // Disable component
var c = go.GetComponent<ModelRenderer>();            // Get single component
var c = go.GetOrAddComponent<ModelRenderer>();       // Get or create
foreach ( var c in go.Components.GetAll() ) { }     // All on this object
foreach ( var c in Scene.GetAll<CameraComponent>() ) { } // All active in scene
Was this helpful?