protected virtual void Initialization() { if (DrawerInitialized) { return; } List <FieldInfo> fieldInfoList; MMInspectorGroupAttribute previousGroupAttribute = default; int fieldInfoLength = MMMonoBehaviourFieldInfo.GetFieldInfo(target, out fieldInfoList); for (int i = 0; i < fieldInfoLength; i++) { MMInspectorGroupAttribute group = Attribute.GetCustomAttribute(fieldInfoList[i], typeof(MMInspectorGroupAttribute)) as MMInspectorGroupAttribute; MMInspectorGroupData groupData; if (group == null) { if (previousGroupAttribute != null && previousGroupAttribute.GroupAllFieldsUntilNextGroupAttribute) { _shouldDrawBase = false; if (!GroupData.TryGetValue(previousGroupAttribute.GroupName, out groupData)) { GroupData.Add(previousGroupAttribute.GroupName, new MMInspectorGroupData { GroupAttribute = previousGroupAttribute, GroupHashSet = new HashSet <string> { fieldInfoList[i].Name }, GroupColor = MMColors.GetColorAt(previousGroupAttribute.GroupColorIndex) }); } else { groupData.GroupColor = MMColors.GetColorAt(previousGroupAttribute.GroupColorIndex); groupData.GroupHashSet.Add(fieldInfoList[i].Name); } } continue; } previousGroupAttribute = group; if (!GroupData.TryGetValue(group.GroupName, out groupData)) { bool groupIsOpen = EditorPrefs.GetBool(string.Format($"{group.GroupName}{fieldInfoList[i].Name}{target.GetInstanceID()}"), false); GroupData.Add(group.GroupName, new MMInspectorGroupData { GroupAttribute = group, GroupColor = MMColors.GetColorAt(previousGroupAttribute.GroupColorIndex), GroupHashSet = new HashSet <string> { fieldInfoList[i].Name }, GroupIsOpen = groupIsOpen }); } else { groupData.GroupHashSet.Add(fieldInfoList[i].Name); groupData.GroupColor = MMColors.GetColorAt(previousGroupAttribute.GroupColorIndex); } } SerializedProperty iterator = serializedObject.GetIterator(); if (iterator.NextVisible(true)) { do { FillPropertiesList(iterator); } while (iterator.NextVisible(false)); } DrawerInitialized = true; }
public void ClearGroup() { GroupAttribute = null; GroupHashSet.Clear(); PropertiesList.Clear(); }