Exemplo n.º 1
0
    protected void OnAdd(ReorderableList list)
    {
        int index = KeysProperty.arraySize;

        KeysProperty.InsertArrayElementAtIndex(index);
        ValuesProperty.InsertArrayElementAtIndex(index);
    }
Exemplo n.º 2
0
    protected float GetReorderableElementHeight(int index)
    {
        float keyHeight   = EditorGUI.GetPropertyHeight(KeysProperty.GetArrayElementAtIndex(index));
        float valueHeight = EditorGUI.GetPropertyHeight(ValuesProperty.GetArrayElementAtIndex(index));
        float height      = 8 + Math.Max(keyHeight, valueHeight);

        if (!IsDragging || (IsDragging && elementHeight < height))
        {
            elementHeight = height;
        }
        return(elementHeight);
    }
Exemplo n.º 3
0
    protected virtual void DrawElement(Rect rect, int index, bool isActive, bool isFocused)
    {
        rect.position = new Vector2(rect.position.x + 10, rect.position.y);
        SerializedProperty key   = KeysProperty.GetArrayElementAtIndex(index);
        SerializedProperty value = ValuesProperty.GetArrayElementAtIndex(index);
        float   halfSizeX        = rect.size.x / 2;
        float   leftOffset       = 100;
        float   rightOffset      = 58;
        Vector2 sizeKey          = new Vector2(halfSizeX - leftOffset, rect.size.y);
        Vector2 sizeValue        = new Vector2(halfSizeX + rightOffset, rect.size.y);
        Vector2 positionValue    = rect.position + new Vector2(sizeKey.x + 25, 0);

        float oldWidth = EditorGUIUtility.labelWidth;

        EditorGUIUtility.labelWidth = 50;
        OnBeforeDrawProperties();
        rect = DrawPropertiesForElement(new Rect(rect.position, sizeKey), new Rect(positionValue, sizeValue), key, value);
        OnAfterDrawProperties();
        EditorGUIUtility.labelWidth = oldWidth;

        CheckRedBoxForElement(rect, key, index);
    }
Exemplo n.º 4
0
 set => SetValue(ValuesProperty, value);
Exemplo n.º 5
0
 protected void OnReorder(ReorderableList list)
 {
     ValuesProperty.MoveArrayElement(SelectedIndex, list.index);
 }
Exemplo n.º 6
0
 protected void OnRemove(ReorderableList list)
 {
     KeysProperty.DeleteArrayElementAtIndex(SelectedIndex);
     ValuesProperty.DeleteArrayElementAtIndex(SelectedIndex);
 }