public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { AvatarData data = CallFunction <AvatarData>(property, Attribute.Function); if (data == null) { return(LineHeight()); } SerializedProperty dataListProperty = property.FindPropertyRelative("avatarPatternDataList"); return(LineHeight() * (dataListProperty.arraySize + data.GetAllOptionPatterns().Count)); }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { AvatarData data = CallFunction <AvatarData>(property, Attribute.Function); if (data == null) { return; } //パターンデータ(タグとパターン名) EditorGUI.BeginProperty(position, label, property); var dataListProperty = property.FindPropertyRelative("avatarPatternDataList"); float h = LineHeight(); for (int i = 0; i < dataListProperty.arraySize; ++i) { var childProperty = dataListProperty.GetArrayElementAtIndex(i); var tagProperty = childProperty.FindPropertyRelative("tag"); var patternNameProperty = childProperty.FindPropertyRelative("patternName"); if (tagProperty.stringValue == data.OptionTag) { continue; } List <string> patternNameList = new List <string> { "None" }; patternNameList.AddRange(data.GetPatternNameListInTag(tagProperty.stringValue)); int currentPatternIndex = patternNameList.FindIndex(x => x == patternNameProperty.stringValue); currentPatternIndex = Mathf.Max(0, currentPatternIndex); position.height = h; int index = EditorGUI.Popup(position, tagProperty.stringValue, currentPatternIndex, patternNameList.ToArray()); patternNameProperty.stringValue = patternNameList[index]; position.y += h; } //オプションデータ(アクセサリなどの表示) var optionPatternNameListProperty = property.FindPropertyRelative("optionPatternNameList"); List <string> list = DrawerUtil.GetStringList(optionPatternNameListProperty); List <string> newList = new List <string>(); bool hasChanged = false; foreach (var optionPattern in data.GetAllOptionPatterns()) { bool check = list.FindIndex(x => x == optionPattern) >= 0; bool check1 = EditorGUI.Toggle(position, optionPattern, check); if (check != check1) { hasChanged = true; check = check1; } if (check) { newList.Add(optionPattern); } position.y += h; } if (hasChanged) { DrawerUtil.SetStringArray(optionPatternNameListProperty, newList); } EditorGUI.EndProperty(); }