[ Web Proxy ]
URL:
Viewing: https://docs.unity3d.com/ScriptReference/ObjectPreview.html [Back]  [Original]

Unity - Scripting API: ObjectPreview
Version: Unity 6.5 (6000.5)
    • Supported
    • Legacy
    LanguageEnglish
    • C#

    ObjectPreview

    class in 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

    Submission failed

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

    Close
    Your name Your email Suggestion* Submit suggestion

    Cancel

    Description

    Base Class to derive from when creating Custom Previews.

    You specify which type is the preview for by using the CustomPreview attribute derived from ObjectPreview. 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.

    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
    targetThe object currently being previewed.

    Public Methods

    Method Description
    CleanupUse this function to release resources allocated by the ObjectPreview implementation.
    CreatePreviewSee Editor.CreatePreview.
    DrawPreviewThis is the first entry point for Preview Drawing.
    GetInfoStringImplement this method to show object information on top of the object preview.
    GetPreviewTitleOverride this method if you want to change the label of the Preview area.
    HasPreviewGUICan this component be Previewed in its current state?
    InitializeCalled when the Preview gets created with the objects being previewed.
    MoveNextTargetCalled to iterate through the targets, this will be used when previewing more than one target.
    OnInteractivePreviewGUIImplement to create your own interactive custom preview. Interactive custom previews are used in the preview area of the inspector and the object selector.
    OnPreviewGUIImplement to create your own custom preview for the preview area of the inspector, primary editor headers and the object selector.
    OnPreviewSettingsOverride this method if you want to show custom controls in the preview header.
    ResetTargetCalled to Reset the target before iterating through them.

    Web Proxy Viewer  |  New URL  |  Original Page