if (rigidbody != null){rigidbody.AddForce(force);}var targetName = target != null? target.name : "None";Smooth Operator
Smooth Operator is a Unity extension focused on one problem: Unity objects do not behave like normal CLR references around `?.` and `??`. This tool makes those operators usable without the missing-reference surprises that normally come with Unity’s custom null model.
The Problem
Unity uses a custom equality implementation on `UnityEngine.Object` to detect destroyed native-side objects. The null conditional operator and null coalescing operator cannot use that custom behavior, because those operators are not overloadable in C#.
That means code that looks like ordinary C# can still behave incorrectly with Unity objects after the native object has been destroyed. Smooth Operator exists to close that gap.
Unity can make a destroyed object compare equal to null through its overloaded equality rules, but `?.` and `??` still use regular reference null checks. That mismatch is the core issue Smooth Operator addresses.
Before / After
The old version works, but it spreads the null handling across more branches and more visual noise. Smooth Operator compresses the same intent into code that is easier to read in motion.
if (rigidbody != null){rigidbody.AddForce(force);}var targetName = target != null? target.name : "None";rigidbody?.AddForce(force);var targetName = target?.name?? "None";The safety checks stay in the code path without forcing the surrounding method to sprawl.
Nothing about the gameplay logic changes. The syntax just becomes easier to scan and maintain.
Smooth Operator keeps the result aligned with Unity object semantics instead of plain CLR null checks.
How It Works
Smooth Operator transforms the relevant code paths so Unity’s overloaded null check is used instead of a plain reference null check. The result is that `?.` and `??` behave the way Unity developers expect when destroyed objects are involved.
FAQ
Unity has a custom `==` implementation that checks whether the native-side object has been destroyed. The `?.` and `??` operators cannot be overridden, so they cannot participate in that custom behavior.
The overhead is negligible, and the resulting behavior is equivalent to using Unity’s regular overloaded null check in an `if` statement.
The problem is often explained in terms of Unity GameObjects, but the underlying issue is Unity’s object null semantics more broadly. The key point is safe null-operator use with Unity objects.
Yes. Build pipelines are supported.
No extra configuration is needed after import. The package is intended to handle the integration on its own.
You can, but the whole point of the tool is to stop writing around the engine limitation when modern C# syntax would otherwise be clearer and less repetitive.
Get Smooth Operator
Available on the Unity Asset Store.