# ObjectChangeKind

> This enumeration describes the different kind of changes that can be tracked in an ObjectChangeEventStream. Each event has a corresponding type in ObjectChangeEvents.

## Definition

* **Type:** Enum
* **Namespace:** [UnityEditor](/engine/6000.6/script-reference/unityeditor.md)
* **Assembly:** UnityEditor.CoreModule

```csharp
public enum ObjectChangeKind : ushort
```

## Examples

```csharp
using UnityEditor;
using UnityEngine;

[InitializeOnLoad]
public class ObjectChangeEventsExample
{
    static ObjectChangeEventsExample()
    {
        ObjectChangeEvents.changesPublished += ChangesPublished;
    }

    static void ChangesPublished(ref ObjectChangeEventStream stream)
    {
        for (int i = 0; i < stream.length; ++i)
        {
            var type = stream.GetEventType(i);
            switch (type)
            {
                case ObjectChangeKind.ChangeScene:
                    stream.GetChangeSceneEvent(i, out var changeSceneEvent);
                    Debug.Log($"{type}: {changeSceneEvent.scene}");
                    break;

                case ObjectChangeKind.CreateGameObjectHierarchy:
                    stream.GetCreateGameObjectHierarchyEvent(i, out var createGameObjectHierarchyEvent);
                    var newGameObject = EditorUtility.EntityIdToObject(createGameObjectHierarchyEvent.entityId) as GameObject;
                    Debug.Log($"{type}: {newGameObject} in scene {createGameObjectHierarchyEvent.scene}.");
                    break;

                case ObjectChangeKind.ChangeGameObjectStructureHierarchy:
                    stream.GetChangeGameObjectStructureHierarchyEvent(i, out var changeGameObjectStructureHierarchy);
                    var gameObject = EditorUtility.EntityIdToObject(changeGameObjectStructureHierarchy.entityId) as GameObject;
                    Debug.Log($"{type}: {gameObject} in scene {changeGameObjectStructureHierarchy.scene}.");
                    break;

                case ObjectChangeKind.ChangeGameObjectStructure:
                    stream.GetChangeGameObjectStructureEvent(i, out var changeGameObjectStructure);
                    var gameObjectStructure = EditorUtility.EntityIdToObject(changeGameObjectStructure.entityId) as GameObject;
                    Debug.Log($"{type}: {gameObjectStructure} in scene {changeGameObjectStructure.scene}.");
                    break;

                case ObjectChangeKind.ChangeGameObjectParent:
                    stream.GetChangeGameObjectParentEvent(i, out var changeGameObjectParent);
                    var gameObjectChanged = EditorUtility.EntityIdToObject(changeGameObjectParent.entityId) as GameObject;
                    var newParentGo = EditorUtility.EntityIdToObject(changeGameObjectParent.newParentEntityId) as GameObject;
                    var previousParentGo = EditorUtility.EntityIdToObject(changeGameObjectParent.previousParentEntityId) as GameObject;
                    Debug.Log($"{type}: {gameObjectChanged} from {previousParentGo} to {newParentGo} from scene {changeGameObjectParent.previousScene} to scene {changeGameObjectParent.newScene}.");
                    break;

                case ObjectChangeKind.ChangeGameObjectOrComponentProperties:
                    stream.GetChangeGameObjectOrComponentPropertiesEvent(i, out var changeGameObjectOrComponent);
                    var goOrComponent = EditorUtility.EntityIdToObject(changeGameObjectOrComponent.entityId);
                    if (goOrComponent is GameObject go)
                    {
                        Debug.Log($"{type}: GameObject {go} change properties in scene {changeGameObjectOrComponent.scene}.");
                    }
                    else if (goOrComponent is Component component)
                    {
                        Debug.Log($"{type}: Component {component} change properties in scene {changeGameObjectOrComponent.scene}.");
                    }
                    break;

                case ObjectChangeKind.DestroyGameObjectHierarchy:
                    stream.GetDestroyGameObjectHierarchyEvent(i, out var destroyGameObjectHierarchyEvent);
                    // The destroyed GameObject can not be converted with EditorUtility.EntityIdToObject as it has already been destroyed.
                    var destroyParentGo = EditorUtility.EntityIdToObject(destroyGameObjectHierarchyEvent.parentEntityId) as GameObject;
                    Debug.Log($"{type}: {destroyGameObjectHierarchyEvent.entityId} with parent {destroyParentGo} in scene {destroyGameObjectHierarchyEvent.scene}.");
                    break;

                case ObjectChangeKind.CreateAssetObject:
                    stream.GetCreateAssetObjectEvent(i, out var createAssetObjectEvent);
                    var createdAsset = EditorUtility.EntityIdToObject(createAssetObjectEvent.entityId);
                    var createdAssetPath = AssetDatabase.GUIDToAssetPath(createAssetObjectEvent.guid);
                    Debug.Log($"{type}: {createdAsset} at {createdAssetPath} in scene {createAssetObjectEvent.scene}.");
                    break;

                case ObjectChangeKind.DestroyAssetObject:
                    stream.GetDestroyAssetObjectEvent(i, out var destroyAssetObjectEvent);
                    // The destroyed asset can not be converted with EditorUtility.EntityIdToObject as it has already been destroyed.
                    Debug.Log($"{type}: Instance Id {destroyAssetObjectEvent.entityId} with Guid {destroyAssetObjectEvent.guid} in scene {destroyAssetObjectEvent.scene}.");
                    break;

                case ObjectChangeKind.ChangeAssetObjectProperties:
                    stream.GetChangeAssetObjectPropertiesEvent(i, out var changeAssetObjectPropertiesEvent);
                    var changeAsset = EditorUtility.EntityIdToObject(changeAssetObjectPropertiesEvent.entityId);
                    var changeAssetPath = AssetDatabase.GUIDToAssetPath(changeAssetObjectPropertiesEvent.guid);
                    Debug.Log($"{type}: {changeAsset} at {changeAssetPath} in scene {changeAssetObjectPropertiesEvent.scene}.");
                    break;

                case ObjectChangeKind.UpdatePrefabInstances:
                    stream.GetUpdatePrefabInstancesEvent(i, out var updatePrefabInstancesEvent);
                    string s = "";
                    s += $"{type}: scene {updatePrefabInstancesEvent.scene}. Instances ({updatePrefabInstancesEvent.entityIds.Length}):\n";
                    foreach (var prefabId in updatePrefabInstancesEvent.entityIds)
                    {
                        s += EditorUtility.EntityIdToObject(prefabId).ToString() + "\n";
                    }
                    Debug.Log(s);
                    break;
            }
        }
    }
}
```

## Fields

| Value                                                                                                                                          | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ---------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [ChangeAssetObjectProperties](/engine/6000.6/script-reference/unityeditor/objectchangekind/changeassetobjectproperties.md)                     | A change of this type indicates that a property of an asset object in memory has changed. This happens for example when [Undo.RecordObject](/engine/6000.6/script-reference/unityeditor/undo/recordobject.md) is used with an instance of an asset (e.g. [Texture](/engine/6000.6/script-reference/unityengine/texture.md)). Note that this only covers changes to asset objects in memory and not changes to assets in the project on disk.                                                 |
| [ChangeChildrenOrder](/engine/6000.6/script-reference/unityeditor/objectchangekind/changechildrenorder.md)                                     | A change of this type indicates that a child has been reordered in the hierarchy under the same parent. This happens when [Undo.RegisterChildrenOrderUndo](/engine/6000.6/script-reference/unityeditor/undo/registerchildrenorderundo.md) is called or when reordering a child in the hierarchy under the same parent.                                                                                                                                                                       |
| [ChangeGameObjectOrComponentProperties](/engine/6000.6/script-reference/unityeditor/objectchangekind/changegameobjectorcomponentproperties.md) | A change of this type indicates that a property of a [GameObject](/engine/6000.6/script-reference/unityengine/gameobject.md) or [Component](/engine/6000.6/script-reference/unityengine/component.md) has changed. This happens for example when [Undo.RecordObject](/engine/6000.6/script-reference/unityeditor/undo/recordobject.md) is used with an instance of a [Component](/engine/6000.6/script-reference/unityengine/component.md).                                                  |
| [ChangeGameObjectParent](/engine/6000.6/script-reference/unityeditor/objectchangekind/changegameobjectparent.md)                               | A change of this type indicates that the parent of a [GameObject](/engine/6000.6/script-reference/unityengine/gameobject.md) has changed. This happens when [Undo.SetTransformParent](/engine/6000.6/script-reference/unityeditor/undo/settransformparent.md) or [SceneManager.MoveGameObjectToScene](/engine/6000.6/script-reference/unityengine/scenemanagement/scenemanager/movegameobjecttoscene.md) is used.                                                                            |
| [ChangeGameObjectStructure](/engine/6000.6/script-reference/unityeditor/objectchangekind/changegameobjectstructure.md)                         | A change of this type indicates that the structure of a [GameObject](/engine/6000.6/script-reference/unityengine/gameobject.md) has changed. This happens when a component is added to or removed from the [GameObject](/engine/6000.6/script-reference/unityengine/gameobject.md) using [Undo.AddComponent](/engine/6000.6/script-reference/unityeditor/undo/addcomponent.md) or [Undo.DestroyObjectImmediate](/engine/6000.6/script-reference/unityeditor/undo/destroyobjectimmediate.md). |
| [ChangeGameObjectStructureHierarchy](/engine/6000.6/script-reference/unityeditor/objectchangekind/changegameobjectstructurehierarchy.md)       | A change of this type indicates that the structure of a [GameObject](/engine/6000.6/script-reference/unityengine/gameobject.md) has changed and any [GameObject](/engine/6000.6/script-reference/unityengine/gameobject.md) in the hierarchy below it might have changed. This happens for example when [Undo.RegisterFullObjectHierarchyUndo](/engine/6000.6/script-reference/unityeditor/undo/registerfullobjecthierarchyundo.md) is used.                                                 |
| [ChangeRootOrder](/engine/6000.6/script-reference/unityeditor/objectchangekind/changerootorder.md)                                             | A change of this type indicates that a GameObject placed at the scene root has been reordered in the hierarchy. This happens when [Undo.SetSiblingIndex](/engine/6000.6/script-reference/unityeditor/undo/setsiblingindex.md) is called or when reordering such a GameObject in the hierarchy under the same scene.                                                                                                                                                                          |
| [ChangeScene](/engine/6000.6/script-reference/unityeditor/objectchangekind/changescene.md)                                                     | A change of this type indicates that an open scene has been changed ("dirtied") without any more specific information available. This happens for example when [EditorSceneManager.MarkSceneDirty](/engine/6000.6/script-reference/unityeditor/scenemanagement/editorscenemanager/markscenedirty.md) is used.                                                                                                                                                                                |
| [CreateAssetObject](/engine/6000.6/script-reference/unityeditor/objectchangekind/createassetobject.md)                                         | A change of this type indicates that an asset object has been created. This happens for example when [Undo.RegisterCreatedObjectUndo](/engine/6000.6/script-reference/unityeditor/undo/registercreatedobjectundo.md) is used with an instance of an asset (e.g. [Texture](/engine/6000.6/script-reference/unityengine/texture.md)). Note that this only covers creation of asset objects in memory and not creation of new assets in the project on disk.                                    |
| [CreateGameObjectHierarchy](/engine/6000.6/script-reference/unityeditor/objectchangekind/creategameobjecthierarchy.md)                         | A change of this type indicates that a [GameObject](/engine/6000.6/script-reference/unityengine/gameobject.md) has been created, possibly with additional objects below it in the hierarchy. This happens for example when [Undo.RegisterCreatedObjectUndo](/engine/6000.6/script-reference/unityeditor/undo/registercreatedobjectundo.md) is used with a [GameObject](/engine/6000.6/script-reference/unityengine/gameobject.md).                                                           |
| [DestroyAssetObject](/engine/6000.6/script-reference/unityeditor/objectchangekind/destroyassetobject.md)                                       | A change of this type indicates that an asset object has been destroyed. This happens for example when [Undo.DestroyObjectImmediate](/engine/6000.6/script-reference/unityeditor/undo/destroyobjectimmediate.md) is used with an instance of an asset (e.g. [Texture](/engine/6000.6/script-reference/unityengine/texture.md)). Note that this only covers destruction of asset objects in memory and not deletion of assets in the project on disk.                                         |
| [DestroyGameObjectHierarchy](/engine/6000.6/script-reference/unityeditor/objectchangekind/destroygameobjecthierarchy.md)                       | A change of this type indicates that a [GameObject](/engine/6000.6/script-reference/unityengine/gameobject.md) and the entire hierarchy below it has been destroyed. This happens for example when [Undo.DestroyObjectImmediate](/engine/6000.6/script-reference/unityeditor/undo/destroyobjectimmediate.md) is used with an [GameObject](/engine/6000.6/script-reference/unityengine/gameobject.md).                                                                                        |
| [None](/engine/6000.6/script-reference/unityeditor/objectchangekind/none.md)                                                                   | Indicates an uninitialized value.                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| [UpdatePrefabInstances](/engine/6000.6/script-reference/unityeditor/objectchangekind/updateprefabinstances.md)                                 | A change of this type indicates that prefab instances in an open scene have been updated due to a change to the source prefab.                                                                                                                                                                                                                                                                                                                                                               |
