-
Enable null-propagation
var rb = GetComponent<Rigidbody>(); rb.Nullable()?.AddForce(Vector3.forward);
-
Safe get component
var rb = GetOrAddComponent<Rigidbody>(); rb.AddForce(Vector3.forward);
-
Unity unmanaged safe-check
Destroy(someUnityObject); print(someUnityObject == null); // true object regularObject = someUnityObject; print(regularObject == null); // false print(regularObject.IsUnityNull()); // true
Find Packages/manifest.json
in your project and edit it to look like this:
{
"dependencies": {
"com.codeavr.unity-object-extensions": "https://github.com/Codeavr/UnityObjectExtensions.git"
}
}
- Unity any version
- Git
- MIT