tag

#components

9 items (9 fixes)

fixes
26.07.22
"A public Reset() on a Component silently shadows the engine's Component.Reset()"

Naming a Component method `public void Reset()` compiles clean and silently hides the engine's own `Component.Reset()`. The only signal is a CS0114 warning, which `dotnet build -v q` never prints. Green is not the same as warning-free: pick a different name (ResetState, Clear) unless you deliberately mean to hook the lifecycle method.

26.07.15a
"A static Func/Action lambda orphaned by hotload throws NotImplementedException"

A static Func<>/Action<> field that holds a lambda survives hotload still pointing at the replaced assembly. Invoking it throws System.NotImplementedException: 'Unable to find matching substitution for a lambda method' in the next Play session, with a green compile. Guard the read with try/catch and self-heal, and re-assign the seam at session start.

26.07.15a
"Components.Get misses a SkinnedModelRenderer on a child object"

Components.Get<SkinnedModelRenderer>() only searches the same GameObject: a renderer on a child returns null, silently no-oping every Set() call.

26.07.22
"FirstOrDefault() on SkinnedModelRenderer can grab clothing, not the body"

On a dressed citizen, GetAllComponents<SkinnedModelRenderer>().FirstOrDefault() can return a bone-merged clothing renderer (a hat) instead of the body, silently, with no null. A sequence probe then reports every clip absent. Select the body renderer explicitly.

26.07.22
"My interface scan returns nothing at runtime"

OfType<IInteractable> on GetAllComponents<Component> returns nothing: GetAllComponents answers off a concrete-type index, so enumerate concrete types (or a shared abstract base) and union them.

26.07.08e
"Naming a property 'Active' shadows Component.Active"

Component.Active is a real inherited member: naming your own bool Active silently shadows the engine's enabled flag. It is a CS0108 warning, not an error, so it ships easily; treat CS0108 as an error in code review.

26.07.08e
"s&box component lifecycle in practice"

OnAwake runs synchronously inside Components.Create: set singletons there; derive from [Property] in OnStart after spawn helpers assign.

26.07.08e
"Scene.GetAllComponents skips disabled components"

A component with Enabled = false is invisible to GetAllComponents: search returns null even though the component exists.

26.07.08e
"The singleton pattern that removes reference-wiring"

static Instance set in OnAwake, cleared in OnDestroy: everything reads Foo.Instance with null-guards, no inspector wiring.

Want to know when new guides or fixes drop? Join the community to help build this out. Report gotchas, flag outdated fixes, or just lurk.

Join the Discord