GameObjectExtensions Class Reference

Contains various static convenience and extension function for Unity GameObjects.

Public Member Functions

delegate Component EditorAddComponentWithUndo (GameObject gameObject, System.Type componentType)
 Defines a delegate signature that takes a GameObject, and component type, and returns a reference to a component. This is used to define the EditorAddComponent member.
 
delegate Object EditorInstanceIDToObjectFunction (int instanceID)
 Delegate Used by editor dll to hook into the EditorUtility.InstanceIDToObject, when present.
 
delegate bool EditorTestObject (Object objectToCheck)
 defines a delegate signature that takes and object and returns bool used to define both EditorIsObjectAPreFab and EditorIsObjectAnAsset members
 

Static Public Member Functions

static T AddComponentAppropriately< T > (this GameObject objectToAddComponent)
 The function check is the application is not playing, and is in the editor. If so, it will call the undo version of AddCompoent.
 
static void DestroyObjectAppropriately (this Object objectToDestroy)
 Use to destroy objects properly whether in the editor or not. Will not destroy a saved asset.
 
static Object InstanceIDToObject (int instanceID)
 Return null when not running in the editor. Otherwise, calls the EditorUtility.InstanceIDToObject function, and returns the result cast to GameObject.
 
static object InstantiateSystemObjectOfType (this object potentialSourceData)
 Not all types will be able to copy the potential source data, only use.Object derived types, and value types
 
static bool IsObjectAnAsset (Object testObject)
 Functions inside of Editor only code, this function will return false when not running in the Editor. When running in the editor, uses AssetDatabase.GetPath to test, and returns the result.
 
static bool IsObjectAPreFab (Object testObject)
 Functions inside of Editor only code, this function will return false when not running in the Editor. When running in the editor, uses PrefabUtility.GetPrefabType to test, and returns the result.
 

Static Public Attributes

static EditorAddComponentWithUndo EditorAddComponent
 This delegate is assigned by editor class GameObjectExtensionEditorComponent, when the editor is initialized.
 
static EditorInstanceIDToObjectFunction EditorInstanceIDToObject
 static instance of the EditorInstanceIDToObjectFunction delegate. It is assigned a value by EyE unity editor dll, if it is present.
 
static EditorTestObject EditorIsObjectAnAsset
 This delegate is assigned by editor class GameObjectExtensionEditorComponent, when the editor is initialized.
 
static EditorTestObject EditorIsObjectAPreFab
 This delegate is assigned by editor class GameObjectExtensionEditorComponent, when the editor is initialized.