s&box docs
GuidesCodeCode Basics

Cheat Sheet

Sometimes you know what you're looking for, but you don't know where it is.

Sometimes you know what you're looking for, but you don't know where it is.

Debugging

NameCode
Logging to consoleLog.Info( $"Hello {username}" );
Drawing to screenDebugOverlay.ScreenText( new Vector2( 50, 50 ), "Hello" );
AssertingAssert.NotNull( obj, "Object was null!" )

Transforms

NameCode
Get GameObject Positionvar p = go.WorldPosition;
Set GameObject Positiongo.WorldPosition = new Vector3( 10, 0, 0 );
Get Local Positionvar p = go.LocalPosition;

GameObjects

NameCode
Find by nameScene.Directory.FindByName( "Cube" ).First();
Find by GuidScene.Directory.FindByGuid( guid );
Creatingvar go = new GameObject();
Deletinggo.Destroy()
Disablinggo.Enabled = false;
Duplicatingvar newGo = go.Clone();
Adding a Taggo.Tags.Add( "player" );
Iterate Childrenforeach( var child in go.Children )
Deleted Checkif ( go.IsValid() )

Components

NameCode
Add componentvar c = go.AddComponent<ModelRenderer>();
Remove componentc.Destroy()
Disablingc.Enabled = false;
Get GameObjectvar go = c.GameObject;
Get Componentvar c = go.GetComponent<ModelRenderer>();
Get or Addvar c = go.GetOrAddComponent<ModelRenderer>();
Iterateforeach ( var c in go.Components.GetAll() )
Deleted checkif ( c.IsValid() )
Get all activeforeach ( var c in Scene.GetAll<CameraComponent>() )

Referenced API

Canonical API pages mentioned in this guide.

Created at:
Updated at:

On this page