Odin - Inspector and Serializer - Editor Integration
Apr 30, 2019 18:37:35 GMT
tchrisbaker likes this
Post by spinalcord on Apr 30, 2019 18:37:35 GMT
Hello,
Little code modify to make Odin Inspector Serializer more compatible with most of Invectors CustomInspector. You are able to use after the modify attributes like [OnValueChanged] [HideIf] [...], and you get also the sortable list!
Limitations
-You can't use Odins grouping attributes, but this not really necessary. You can use instead Invectors grouping [vEditorToolbar] or [Header].
-It dosn't work with all CustomInspectors.
Steps:
Open:
Assets\Invector-3rdPersonController\Basic Locomotion\Scripts\Generic\Editor\vEditorHelper.cs (Make a backup of the scene and script if you wan't)
change Line:1
using UnityEngine;
to
using UnityEngine; using Sirenix.OdinInspector.Editor;
change Line:46public class vEditorBase : Editor
to
public class vEditorBase : OdinEditor
change Line:72
protected virtual void OnEnable()
to
protected override void OnEnable()
change Line:253
DrawPropertiesExcluding(serializedObject, ignoreProperties);
to
DrawSerializedOdinAttributes(ignoreProperties);
change Line:283DrawPropertiesExcluding(serializedObject, ignoreProperties);
to
DrawSerializedOdinAttributes(ignoreProperties);
change Line:262DrawPropertiesExcluding(serializedObject, ignore_vMono);
to
DrawSerializedOdinAttributes(ignore_vMono);
change Line:283
DrawPropertiesExcluding(serializedObject, ignoreProperties);
to
DrawSerializedOdinAttributes(ignoreProperties);
change Line:299
DrawPropertiesExcluding(serializedObject, ignoreProperties);
to
DrawSerializedOdinAttributes(ignoreProperties);
Add to Line:71
public void DrawSerializedOdinAttributes(string[] IgnoreList = null)
{
var tree = this.Tree;
var obj = this.target as vMonoBehaviour;
InspectorUtilities.BeginDrawPropertyTree(tree, true);
List<string> IgnoreProperties = IgnoreList.vToList();
SerializedProperty prop = serializedObject.GetIterator();
if (prop.NextVisible(true))
{
do
{
var prop_I = tree.GetPropertyAtPath(prop.name);
if(IgnoreProperties != null)
{
if (prop_I != null && IgnoreProperties.Contains(prop.name) == false)
prop_I.Draw();
}
else
{
if (prop_I != null)
prop_I.Draw();
}
}
while (prop.NextVisible(false));
}
InspectorUtilities.EndDrawPropertyTree(tree);
}