Search Unity

UnityEditor.Editor Preview methods vs. UnityEditor.ObjectPreview methods

Discussion in 'Scripting' started by ModLunar, May 10, 2021.

  1. ModLunar

    ModLunar

    Joined:
    Oct 16, 2016
    Posts:
    374
    Both UnityEditor.Editor and UnityEditor.ObjectPreview allow you to create object previews in your custom Inspector, including the same public overridable methods such as:

    • bool HasPreviewGUI()

    • void OnPreviewGUI(Rect, GUIStyle)

    • string GetInfoString()

    What's the difference?
    Is one newer and more recommended than the other?

    The only difference for me right now (that I can see) is that keeping my preview code separate from my Editor (inspector) class could be seen as separation of concerns, if I could separate out the two scripts.
    Though I might imagine it could be useful to have the context of everything in my Editor (inspector) class when drawing the preview..

    Not really sure though which I should use?
    Any ideas?
     
    Yany likes this.