Create powerful and user-friendly editors for you and your team!
This is possible, yes - you should in this case inherit from OdinEditor instead of Editor, and then use Odin's own property system to draw instead of Unity's. In Odin, the PropertyTree and InspectorProperty types correspond to respectively Unity's SerializedObject and SerializedProperty types, and provide similar functionality.
For example, your custom editor might look like this:
[CustomEditor(typeof(MyMonoBehaviour))]
public class CustomOdinEditor : OdinEditor
{
public override void OnInspectorGUI()
{
var tree = this.Tree; // Like this.serializedObject.
var obj = this.target as MyMonoBehaviour;
InspectorUtilities.BeginDrawPropertyTree(tree, true); // This and EndDrawPropertyTree automatically handles a lot of stuff like prefab instance modifications and undo
if (obj.SomeCondition)
{
var someProp1 = tree.GetPropertyAtPath("someProp1"); // Like serializedObject.FindProperty("path")
someProp1.Draw(); // Like EditorGUILayout.PropertyField(property);
}
else
{
var someProp2 = tree.GetPropertyAtPath("someProp2");
someProp2.Draw(new GUIContent("My Label")); // You can also pass custom labels into Draw()
}
InspectorUtilities.EndDrawPropertyTree(tree);
// You can also call base.OnInspectorGUI(); instead if you simply want to prepend or append GUI to the editor.
}
}
In fact, you can draw the entire tree "as usual", IE the default Odin inspector, merely by calling tree.Draw(), which draws all the root level properties of the tree - that is exactly how Odin renders the full default inspector.