Legacy Documentation: Version 4.6(go to latest)
Language: English
  • C#
  • JS
  • Boo

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

ObjectPreview

Namespace: UnityEditor

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Base Class to derive from when creating Custom Previews.

You specify which type is the preview for, by using the ObjectPreview attribute. Below you can see an small example that will display the name of the object being inspected.

[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"); } }

Variables

target The object currently being previewed.

Functions

DrawPreview This is the first entry point for Preview Drawing.
GetInfoString Implement this method to show object information on top of the object preview.
GetPreviewTitle Override this method if you want to change the label of the Preview area.
HasPreviewGUI Whether the current target can be previewed.
Initialize Called when the Preview gets created with the objects being previewed.
MoveNextTarget Called to iterate through the targets, this will be used when previewing more than one target.
OnInteractivePreviewGUI 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 Implement to create your own custom preview for the preview area of the inspector, primary editor headers and the object selector.
OnPreviewSettings Override this method if you want to show custom controls in the preview header.
ResetTarget Called to Reset the target before iterating through them.