SubjectNerd-Unity / ReorderableInspector

Automatic reorderable lists for Unity game engine components
MIT License
485 stars 47 forks source link

Cannot derive from ReorderableArrayInspector #5

Closed rakkarage closed 6 years ago

rakkarage commented 6 years ago

I must already derive from GridBrushEditor (tho i not use any GUI) so I cannot derive from ReorderableArrayInspector!? Why does my CustomPropertyDrawer work in this situation but not Reorderable? Is there any way to make it work? I need to make a custom drawer or a ReorderableArrayInspector Thanks.

https://en.wikipedia.org/wiki/Composition_over_inheritance

edit:

Custom inspectors will not automatically draw arrays as ReorderableLists unless they inherit from ReorderableArrayInspector.

If not auto then how please? tried [Reorderable]...

rakkarage commented 6 years ago

there must be some way to make it work in this situation please?

rakkarage commented 6 years ago

works like this in odin

using Sirenix.OdinInspector.Editor;
using UnityEngine;
using UnityEditor;
public class OdinBrush : GridBrushEditor
{
    OdinEditor editor;
    private void OnGUI()
    {
        if (!editor)
            editor = Editor.CreateEditor(target, typeof(OdinEditor)) as OdinEditor;
        editor.OnInspectorGUI();
    }
}

is there a comparable way to get this working from classed that cannot derive from this? thanks

rakkarage commented 6 years ago

yes, thanks

using System;
using UnityEngine;
using UnityEngine.Tilemaps;
using SubjectNerd.Utilities;
#if UNITY_EDITOR
using UnityEditor;
#endif
[CreateAssetMenu]
[Serializable]
public class TestB : ScriptableObject
{
    public int[] Test;
    public TileOrientation Orientation;
}
#if UNITY_EDITOR
[CustomEditor(typeof(TestB))]
public class TestBEditor : Editor
{
    ReorderableArrayInspector editor;
    public override void OnInspectorGUI()
    {
        if (!editor)
            editor = Editor.CreateEditor(target, typeof(ReorderableArrayInspector)) as ReorderableArrayInspector;
        editor.OnInspectorGUI();
    }
}
#endif