Esempio n. 1
0
        public virtual void Initialization(SerializedProperty currentProperty, MMF_Feedback feedback, bool expandGroupInspectors)
        {
            if (DrawerInitialized)
            {
                return;
            }

            _expandGroupInspectors = expandGroupInspectors;
            _currentProperty       = currentProperty;
            _feedback = feedback;

            List <FieldInfo>           fieldInfoList;
            MMFInspectorGroupAttribute previousGroupAttribute = default;
            int fieldInfoLength = MMF_FieldInfo.GetFieldInfo(feedback, out fieldInfoList);

            for (int i = 0; i < fieldInfoLength; i++)
            {
                MMFInspectorGroupAttribute group = Attribute.GetCustomAttribute(fieldInfoList[i], typeof(MMFInspectorGroupAttribute)) as MMFInspectorGroupAttribute;

                MMFInspectorGroupData groupData;
                if (group == null)
                {
                    if (previousGroupAttribute != null && previousGroupAttribute.GroupAllFieldsUntilNextGroupAttribute)
                    {
                        _shouldDrawBase = false;
                        if (!GroupData.TryGetValue(previousGroupAttribute.GroupName, out groupData))
                        {
                            GroupData.Add(previousGroupAttribute.GroupName, new MMFInspectorGroupData
                            {
                                GroupAttribute = previousGroupAttribute,
                                GroupHashSet   = new HashSet <string> {
                                    fieldInfoList[i].Name
                                },
                                GroupColor = MMFeedbacksColors.GetColorAt(previousGroupAttribute.GroupColorIndex)
                            });
                        }
                        else
                        {
                            groupData.GroupColor = MMFeedbacksColors.GetColorAt(previousGroupAttribute.GroupColorIndex);
                            groupData.GroupHashSet.Add(fieldInfoList[i].Name);
                        }
                    }

                    continue;
                }

                previousGroupAttribute = group;

                if (!GroupData.TryGetValue(group.GroupName, out groupData))
                {
                    bool fallbackOpenState = _expandGroupInspectors;
                    if (group.ClosedByDefault)
                    {
                        fallbackOpenState = false;
                    }
                    bool groupIsOpen = EditorPrefs.GetBool(string.Format($"{group.GroupName}{fieldInfoList[i].Name}{feedback.UniqueID}"), fallbackOpenState);
                    GroupData.Add(group.GroupName, new MMFInspectorGroupData
                    {
                        GroupAttribute = group,
                        GroupColor     = MMFeedbacksColors.GetColorAt(previousGroupAttribute.GroupColorIndex),
                        GroupHashSet   = new HashSet <string> {
                            fieldInfoList[i].Name
                        }, GroupIsOpen = groupIsOpen
                    });
                }
                else
                {
                    groupData.GroupHashSet.Add(fieldInfoList[i].Name);
                    groupData.GroupColor = MMFeedbacksColors.GetColorAt(previousGroupAttribute.GroupColorIndex);
                }
            }


            if (currentProperty.NextVisible(true))
            {
                do
                {
                    FillPropertiesList(currentProperty);
                } while (currentProperty.NextVisible(false));
            }

            DrawerInitialized = true;
        }
Esempio n. 2
0
 public void ClearGroup()
 {
     GroupAttribute = null;
     GroupHashSet.Clear();
     PropertiesList.Clear();
 }