Ejemplo n.º 1
0
        private static void DrawDropdown(Rect position, SerializedProperty property, FieldOption option)
        {
            if (property.propertyType != SerializedPropertyType.Integer)
            {
                position = MightyGUIUtilities.DrawPropertyField(position, property);
                MightyGUIUtilities.DrawHelpBox(position, $"{nameof(SceneDropdownAttribute)} can be used only on int fields");
                return;
            }

            GetDisplayOptions(out var displayOptions, out var values);

            var value = MightyGUIUtilities.DrawDropdown(position, property.displayName, property.intValue,
                                                        values, displayOptions, option);

            if (value != null)
            {
                property.intValue = (int)value;
            }
        }
Ejemplo n.º 2
0
        private static void DrawDropdown(SerializedProperty property, FieldOption option, GUIContent label = null)
        {
            if (property.propertyType != SerializedPropertyType.Integer)
            {
                MightyGUIUtilities.DrawPropertyField(property, label);
                MightyGUIUtilities.DrawHelpBox($"{nameof(SceneDropdownAttribute)} can be used only on int fields");
                return;
            }

            GetDisplayOptions(out var displayOptions, out var values);

            var value = MightyGUIUtilities.DrawDropdown(label ?? EditorGUIUtility.TrTextContent(property.displayName), property.intValue,
                                                        values, displayOptions, option);

            if (value != null)
            {
                property.intValue = (int)value;
            }
        }