Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


GetTypesDerivedFrom

Retrieves an unordered collection of types derived from the T type.
Read time 3 minutesLast updated 6 days ago

Definition

  • Type: Method
  • Namespace: UnityEditor
  • Assembly: UnityEditor.CoreModule

GetTypesDerivedFrom<T>()

Retrieves an unordered collection of types derived from the T type.
public static TypeCache.TypeCollection GetTypesDerivedFrom<T>()

Returns

Type

Description

TypeCollectionReturns an unordered collection of derived types. If assemblyName is specified, returns only types defined in this assembly.

Remarks

This method provides fast access to all classes loaded from a given assembly or all Unity domain assemblies, which are derived from a specific class or implement a specific interface. Base class or interface can be a generic. The order of results is undefined.
using UnityEditor;public class Example{ static void ScanAssetPostprocessors() { var extractedTypes = TypeCache.GetTypesDerivedFrom<AssetPostprocessor>(); foreach (var editors in extractedTypes) { //... } }}
Or classes which implement a specific interface.
using UnityEditor;public interface IExampleInterface {}public class Example{ static void ScanInterfaceImplementers() { var extractedTypes = TypeCache.GetTypesDerivedFrom<IExampleInterface>(); foreach (var editors in extractedTypes) { //... } }}
Note: The returned TypeCache.TypeCollection is read-only and thread-safe. The order of types in the collection is undefined.

GetTypesDerivedFrom(Type)

Retrieves an unordered collection of types derived from the T type.
public static TypeCache.TypeCollection GetTypesDerivedFrom(Type parentType)

Parameters

parentType

Type of a class or interface.

Returns

Type

Description

TypeCollectionReturns an unordered collection of derived types. If assemblyName is specified, returns only types defined in this assembly.

Remarks

This method provides fast access to all classes loaded from a given assembly or all Unity domain assemblies, which are derived from a specific class or implement a specific interface. Base class or interface can be a generic. The order of results is undefined.
using UnityEditor;public class Example{ static void ScanAssetPostprocessors() { var extractedTypes = TypeCache.GetTypesDerivedFrom<AssetPostprocessor>(); foreach (var editors in extractedTypes) { //... } }}
Or classes which implement a specific interface.
using UnityEditor;public interface IExampleInterface {}public class Example{ static void ScanInterfaceImplementers() { var extractedTypes = TypeCache.GetTypesDerivedFrom<IExampleInterface>(); foreach (var editors in extractedTypes) { //... } }}
Note: The returned TypeCache.TypeCollection is read-only and thread-safe. The order of types in the collection is undefined.

GetTypesDerivedFrom<T>(string)

Retrieves an unordered collection of types derived from the T type.
public static TypeCache.TypeCollection GetTypesDerivedFrom<T>(string assemblyName)

Parameters

assemblyName

Optional assembly name.

Returns

Type

Description

TypeCollectionReturns an unordered collection of derived types. If assemblyName is specified, returns only types defined in this assembly.

Remarks

This method provides fast access to all classes loaded from a given assembly or all Unity domain assemblies, which are derived from a specific class or implement a specific interface. Base class or interface can be a generic. The order of results is undefined.
using UnityEditor;public class Example{ static void ScanAssetPostprocessors() { var extractedTypes = TypeCache.GetTypesDerivedFrom<AssetPostprocessor>(); foreach (var editors in extractedTypes) { //... } }}
Or classes which implement a specific interface.
using UnityEditor;public interface IExampleInterface {}public class Example{ static void ScanInterfaceImplementers() { var extractedTypes = TypeCache.GetTypesDerivedFrom<IExampleInterface>(); foreach (var editors in extractedTypes) { //... } }}
Note: The returned TypeCache.TypeCollection is read-only and thread-safe. The order of types in the collection is undefined.

GetTypesDerivedFrom(Type, string)

Retrieves an unordered collection of types derived from the T type.
public static TypeCache.TypeCollection GetTypesDerivedFrom(Type parentType, string assemblyName)

Parameters

parentType

Type of a class or interface.

assemblyName

Optional assembly name.

Returns

Type

Description

TypeCollectionReturns an unordered collection of derived types. If assemblyName is specified, returns only types defined in this assembly.

Remarks

This method provides fast access to all classes loaded from a given assembly or all Unity domain assemblies, which are derived from a specific class or implement a specific interface. Base class or interface can be a generic. The order of results is undefined.
using UnityEditor;public class Example{ static void ScanAssetPostprocessors() { var extractedTypes = TypeCache.GetTypesDerivedFrom<AssetPostprocessor>(); foreach (var editors in extractedTypes) { //... } }}
Or classes which implement a specific interface.
using UnityEditor;public interface IExampleInterface {}public class Example{ static void ScanInterfaceImplementers() { var extractedTypes = TypeCache.GetTypesDerivedFrom<IExampleInterface>(); foreach (var editors in extractedTypes) { //... } }}
Note: The returned TypeCache.TypeCollection is read-only and thread-safe. The order of types in the collection is undefined.