예제 #1
0
        static ReorderableList BuildEntryListUI(SerializedProperty entriesProp)
        {
            ReorderableList list = new ReorderableList(entriesProp.serializedObject, entriesProp, true, true, true, true);

            list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => {
                EditorGUI.PropertyField(rect, entriesProp.GetArrayElementAtIndex(index));
            };
            list.draggable               = true;
            list.elementHeight           = OscMappingEntryDrawer.GetPropertyHeight();
            list.drawNoneElementCallback = (rect) => { /* nothing please */ };
            // Remove duplicates methods on add.
            list.onAddCallback = ( ReorderableList l ) => {
                entriesProp.arraySize++;
                SerializedProperty newEntryProp         = entriesProp.GetArrayElementAtIndex(entriesProp.arraySize - 1);
                SerializedProperty targetMethodNameProp = newEntryProp.FindPropertyRelative("targetMethodName");
                SerializedProperty targetParamAssemblyQualifiedNameProp = newEntryProp.FindPropertyRelative("targetParamAssemblyQualifiedName");
                targetMethodNameProp.stringValue = "";
                targetParamAssemblyQualifiedNameProp.stringValue = "";
            };
            // Set the color of the selected list item
            list.drawElementBackgroundCallback = (rect, index, active, focused) => {
                if (active)
                {
                    EditorGUI.DrawRect(rect, new Color32(61, 96, 145, 255));
                }
            };
            return(list);
        }
예제 #2
0
        public override float GetPropertyHeight(SerializedProperty mappingProp, GUIContent label)
        {
            SerializedProperty typeProp    = mappingProp.FindPropertyRelative("_type");
            SerializedProperty entriesProp = mappingProp.FindPropertyRelative("_entries");

            float elementHeight = OscMappingEntryDrawer.GetPropertyHeight();

            return(EditorGUIUtility.singleLineHeight * 2 + elementHeight * Mathf.Max(entriesProp.arraySize, 1) + entriesMarginTop + entriesMarginBottom + verticalBoxPadding * 2);
        }