Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


IsNotNull

Assert that the value is not null.
Read time 1 minuteLast updated 6 days ago

Definition

IsNotNull<T>(T)

Assert that the value is not null.
[Conditional("UNITY_ASSERTIONS")]public static void IsNotNull<T>(T value) where T : class

Parameters

value

T
The Object or type being checked for.

Examples

using UnityEngine;using UnityEngine.Assertions;public class AssertionExampleClass : MonoBehaviour{ MyClass myClassReference; void Update() { // Make sure the myClassReference reference is set Assert.IsNotNull(myClassReference); }}public class MyClass {}

IsNotNull<T>(T, string)

Assert that the value is not null.
[Conditional("UNITY_ASSERTIONS")]public static void IsNotNull<T>(T value, string message) where T : class

Parameters

value

T
The Object or type being checked for.

message

The string used to describe the Assert.

Examples

using UnityEngine;using UnityEngine.Assertions;public class AssertionExampleClass : MonoBehaviour{ MyClass myClassReference; void Update() { // Make sure the myClassReference reference is set Assert.IsNotNull(myClassReference); }}public class MyClass {}

IsNotNull(Object, string)

Assert that the value is not null.
[Conditional("UNITY_ASSERTIONS")]public static void IsNotNull(Object value, string message)

Parameters

value

The Object or type being checked for.

message

The string used to describe the Assert.

Examples

using UnityEngine;using UnityEngine.Assertions;public class AssertionExampleClass : MonoBehaviour{ MyClass myClassReference; void Update() { // Make sure the myClassReference reference is set Assert.IsNotNull(myClassReference); }}public class MyClass {}