# ObjectPreview

> Base Class to derive from when creating Custom Previews.

## Definition

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

```csharp
public class ObjectPreview
```

## Remarks

You specify which type is the preview for by using the CustomPreview attribute derived from [ObjectPreview](/engine/6000.6/script-reference/unityeditor/objectpreview.md). Below you can see an small example that will display the name of the object being inspected.  The preview window will appear at the bottom of the Inspector window.

## Examples

```csharp
using UnityEngine;
using UnityEditor;

[CustomPreview(typeof(GameObject))]
public class MyPreview : ObjectPreview
{
    public override bool HasPreviewGUI()
    {
        return true;
    }

    public override void OnPreviewGUI(Rect r, GUIStyle background)
    {
        GUI.Label(r, target.name + " is being previewed");
    }
}
```

## Properties

| Property                                                                      | Description                           |
| ----------------------------------------------------------------------------- | ------------------------------------- |
| [target](/engine/6000.6/script-reference/unityeditor/objectpreview/target.md) | The object currently being previewed. |

## Methods

| Method                                                                                                          | Description                                                                                                                                                 |
| --------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [Cleanup](/engine/6000.6/script-reference/unityeditor/objectpreview/cleanup.md)                                 | Use this function to release resources allocated by the ObjectPreview implementation.                                                                       |
| [CreatePreview](/engine/6000.6/script-reference/unityeditor/objectpreview/createpreview.md)                     | See [Editor.CreatePreview](/engine/6000.6/script-reference/unityeditor/editor/createpreview.md).                                                            |
| [DrawPreview](/engine/6000.6/script-reference/unityeditor/objectpreview/drawpreview.md)                         | This is the first entry point for Preview Drawing.                                                                                                          |
| [GetInfoString](/engine/6000.6/script-reference/unityeditor/objectpreview/getinfostring.md)                     | Implement this method to show object information on top of the object preview.                                                                              |
| [GetPreviewTitle](/engine/6000.6/script-reference/unityeditor/objectpreview/getpreviewtitle.md)                 | Override this method if you want to change the label of the Preview area.                                                                                   |
| [HasPreviewGUI](/engine/6000.6/script-reference/unityeditor/objectpreview/haspreviewgui.md)                     | Can this component be Previewed in its current state?                                                                                                       |
| [Initialize](/engine/6000.6/script-reference/unityeditor/objectpreview/initialize.md)                           | Called when the Preview gets created with the objects being previewed.                                                                                      |
| [MoveNextTarget](/engine/6000.6/script-reference/unityeditor/objectpreview/movenexttarget.md)                   | Called to iterate through the targets, this will be used when previewing more than one target.                                                              |
| [OnInteractivePreviewGUI](/engine/6000.6/script-reference/unityeditor/objectpreview/oninteractivepreviewgui.md) | Implement to create your own interactive custom preview. Interactive custom previews are used in the preview area of the inspector and the object selector. |
| [OnPreviewGUI](/engine/6000.6/script-reference/unityeditor/objectpreview/onpreviewgui.md)                       | Implement to create your own custom preview for the preview area of the inspector, primary editor headers and the object selector.                          |
| [OnPreviewSettings](/engine/6000.6/script-reference/unityeditor/objectpreview/onpreviewsettings.md)             | Override this method if you want to show custom controls in the preview header.                                                                             |
| [ResetTarget](/engine/6000.6/script-reference/unityeditor/objectpreview/resettarget.md)                         | Called to Reset the target before iterating through them.                                                                                                   |
