Skip to content

Unity Object Extension

Andrzej Kebab edited this page Feb 4, 2024 · 3 revisions

UtilityLibrary.Unity.Runtime

Find

FindObjects(Type type)

Finds all objects of a specified type in the scene.

Object[] foundObjects = UnityObjectExtension.FindObjects(typeof(MyType));

Parameters:

  • type: The specified type of objects to find.

Returns:

  • Object[]: An array of objects of the specified type.

FindObjects<T>()

Finds all objects of a specified type in the scene.

MyType[] foundObjects = UnityObjectExtension.FindObjects<MyType>();

Type Parameters:

  • T: The specified type of objects to find.

Returns:

  • T[]: An array of objects of the specified type.

Destroy

Destroy(this Object obj)

Destroys the given Unity Object. This method provides a way to destroy an Object immediately if the application is not playing (in the Unity Editor), or normally if the application is playing.

Object myObject = GetObject();
myObject.Destroy();

Parameters:

  • obj: The Unity Object to destroy.

DestroyImmediate(this Object obj)

Destroys the object immediately using Object.DestroyImmediate.

Object myObject = GetObject();
myObject.DestroyImmediate();

Parameters:

  • obj: The object to destroy immediately.

Clone this wiki locally