Compatibility with Odin Inspector

  08. Compatibility No Comments

Odin - Inspector and Serializer

If you are an Odin Inspector user, you will be able to hold on to the Odin experience you have gotten used to inside Power Inspector. You can combine the best of both words; Odin’s comprehensive attribute drawer collection being drawn inside Power Inspector, where you have your back and forward buttons, a search box, split view, Debug Mode+ and more to boost your workflow.

To use the two of them together you must make a decision about which one of them will handle drawing the class members of targets within the inspector.

For classes where you are using Odin’s inspector-related attributes, you will likely want to let Odin handle the drawing. This ensures that all attribute enhancements are in full effect inside Power Inspector.

For classes where you are not using Odin’s inspector-related attributes, you can let Power Inspector handle the drawing. However if you would like to let Odin handle drawing of all class members across the board, that is also totally possible.

If you only want to use Odin’s serializer, but don’t plan on using any of the attributes that it offers, then you can let Power Inspector handle the drawing of all classes without any issues.

Odin Attribute Conversion Support

Odin doesn’t use PropertyDrawers for drawing attribute-decorated fields, but has a totally custom drawer system which only functions inside Odin’s own custom Editor. This makes it difficult to slip in Odin’s attribute-based enhancements into Power Inspector at the field-level, pretty much necessitating the use of Odin’s custom Editor inside Power Inspector.

Despite this difficulty as of Power Inspector 1.3.1 some of Odin’s attributes are now in fact supported even inside Power Inspector’s own drawers. This is made possible by a new system called PluginAttributeConverterProvider which can convert a subset of Odin’s attributes into corresponding Power Inspector attributes.

The Odin attributes currently supported when using Power Inspector’s drawers are as follows:

  • ShowInInspectorAttribute
  • ButtonAttribute
  • ReadOnlyAttribute
  • RequiredAttribute
  • TitleAttribute
  • InfoBoxAttribute
  • DetailedInfoBoxAttribute
  • ShowIfAttribute
  • DisableIfAttribute
  • DisplayAsStringAttribute
  • MultiLinePropertyAttribute
  • PropertySpaceAttribute
  • InlinePropertyAttribute

Note that the equivalent Power Inspector attribute drawers won’t necessarily be completely identical to the ones used by Odin Inspector – just close enough in terms of functionality.

Which Drawer Should I Use By Default?

The best way to figure this out is to try them both out for yourself and see which one you like better!

When using Power Inspector you get things like enhanced keyboard support and an enhanced Object reference field, but Odin Inspector has its own set of enhancements it offers as well.

Having Power Inspector Draw All Class Members

To make Power Inspector draw all class members set the preference item Use Editors Over Drawers to Only If Has Custom Editor.

Having Odin Inspector Draw All Class Members

To make Odin draw all class members set the preference item Use Editors Over Drawers to Based On Plug-ins or Always.

Selecting Drawer For Each Type

If you set the preference item Use Editors Over Drawers set to Based On Plug-in Preferences (the default setting), then you will be able to control exactly which types are drawn by which plug-in.

You can configure the drawer for each type using the Preferences window in Odin Inspector.

  1. Select Edit > Preferences.
  2. Select the Odin Inspector view and click the Show Odin Preferences button.
  3. Select the Editor Types view.
  4. Make sure that Enable Odin In Inspector is enabled.
  5. In the Draw Odin for list select all the types for which you would like Odin Inspector to handle the drawing. Power Inspector will handle drawing for all the remaining types.

On Script Organization

Since the types listed in the Editor Types view are organized by namespace, using your namespaces to separate types that you want drawn by Odin Inspector can be a smart idea.

If you do this, you can enable Odin Inspector for all the types in that namespace with a single click.

Here is an example:

using UnityEngine;

namespace MyCompany.OdinEnhanced
	public class ExampleComponent : MonoBehaviour
		public GameObject Prefab;