Show / Hide Table of Contents

Class GetOrAddComponentExtension

This class holds the GetOrAddComponent extension method variants.

Inheritance
System.Object
GetOrAddComponentExtension
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: GlitchedPolygons.ExtensionMethods
Assembly: UnityScriptsLibrary.dll
Syntax
public static class GetOrAddComponentExtension

Methods

| Improve this Doc View Source

GetOrAddComponent<T>(Component)

Tries to get the component on this Component and adds one if there wasn't one attached already.

Declaration
public static T GetOrAddComponent<T>(this Component component)
    where T : Component
Parameters
Type Name Description
Component component

The Component whose component you want to get or add.

Returns
Type Description
T

The component.

Type Parameters
Name Description
T

The type of Component to get or add.

| Improve this Doc View Source

GetOrAddComponent<T>(GameObject)

Tries to get the component on this GameObject and adds one if there wasn't one attached already.

Declaration
public static T GetOrAddComponent<T>(this GameObject gameObject)
    where T : Component
Parameters
Type Name Description
GameObject gameObject

The GameObject whose component you want to get or add.

Returns
Type Description
T

The component.

Type Parameters
Name Description
T

The type of Component to get or add.

  • Improve this Doc
  • View Source
Back to top Generated by DocFX