Ejemplo n.º 1
0
 private static IEnumerable <IGrouping <string, SerializedProperty> > GetGroupedProperties(IEnumerable <SerializedProperty> properties)
 {
     return(properties
            .Where(p => PropertyUtility.GetAttribute <BoxGroupAttribute>(p) != null)
            .GroupBy(p => PropertyUtility.GetAttribute <BoxGroupAttribute>(p).Name));
 }
Ejemplo n.º 2
0
        protected void DrawSerializedProperties()
        {
            serializedObject.Update();

            // Draw non-grouped serialized properties
            foreach (var property in GetNonGroupedProperties(_serializedProperties))
            {
                if (property.name.Equals("m_Script", System.StringComparison.Ordinal))
                {
                    GUI.enabled = false;
                    EditorGUILayout.PropertyField(property);
                    GUI.enabled = true;
                }
                else
                {
                    NaughtyEditorGUI.PropertyField_Layout(property, true);
                }
            }

            // Draw grouped serialized properties
            foreach (var group in GetGroupedProperties(_serializedProperties))
            {
                IEnumerable <SerializedProperty> visibleProperties = group.Where(p => PropertyUtility.IsVisible(p));
                if (!visibleProperties.Any())
                {
                    continue;
                }

                EColor newColor = EColor.Gray;
                foreach (var property in visibleProperties)
                {
                    newColor = PropertyUtility.GetAttribute <BoxGroupAttribute>(property).myColor;
                    if (newColor != EColor.Gray)
                    {
                        break;
                    }
                }
                bool show = BeginBoxGroup_Layout(group.Key, newColor);
                if (show)
                {
                    foreach (var property in visibleProperties)
                    {
                        NaughtyEditorGUI.PropertyField_Layout(property, true);
                    }
                }

                NaughtyEditorGUI.EndBoxGroup_Layout();
            }

            serializedObject.ApplyModifiedProperties();
        }
Ejemplo n.º 3
0
 private static IEnumerable <SerializedProperty> GetNonGroupedProperties(IEnumerable <SerializedProperty> properties)
 {
     return(properties.Where(p => PropertyUtility.GetAttribute <BoxGroupAttribute>(p) == null));
 }