コード例 #1
0
        public void DrawEnumList()
        {
            var typeNameCompare        = new NameCompare(CompareItemTypeName);
            var typeDescriptionCompare = new DescriptionCompare(CompareItemTypeDescription);
            var attrNameCompare        = new NameCompare(CompareItemAttbiuteName);
            var attrDescriptionCompare = new DescriptionCompare(CompareItemAttributeDescription);

            DrawList(serializedObject.FindProperty("itemTypeEnumValues"), serializedObject.FindProperty("itemTypeEnumFormats"), typeNameCompare, typeDescriptionCompare);
            DrawList(serializedObject.FindProperty("itemAttributesEnumValues"), serializedObject.FindProperty("itemAttributesEnumFormats"), attrNameCompare, attrDescriptionCompare);
        }
コード例 #2
0
        void DrawList(SerializedProperty nameList, SerializedProperty nameFormatList, NameCompare compareName, DescriptionCompare compareDescription)
        {
            GUILayout.BeginVertical("box");
            {
                GUILayout.Box(nameList.displayName, GUILayout.ExpandWidth(true));
                GUILayout.BeginHorizontal();
                {
                    GUILayout.BeginVertical(GUILayout.ExpandWidth(true));
                    {
                        GUI.color = Color.white;
                        GUILayout.Box("Name", GUILayout.ExpandWidth(true));
                        for (int i = 0; i < nameList.arraySize; i++)
                        {
                            SerializedProperty name = nameList.GetArrayElementAtIndex(i);
                            GUI.color = compareName(name.stringValue)? Color.grey: Color.white;
                            EditorGUILayout.PropertyField(name, GUIContent.none, GUILayout.ExpandWidth(true), GUILayout.Height(EditorGUIUtility.singleLineHeight));
                            InsertPlaceHolder(name.stringValue, new GUIContent("...Enum Name"));
                        }
                    }
                    GUILayout.EndVertical();

                    GUILayout.BeginVertical(GUILayout.ExpandWidth(true));
                    {
                        if (nameList.arraySize != nameFormatList.arraySize)
                        {
                            nameFormatList.arraySize = nameList.arraySize;
                        }
                        GUI.color = Color.white;
                        GUILayout.Box("Format", GUILayout.ExpandWidth(true));
                        for (int i = 0; i < nameFormatList.arraySize; i++)
                        {
                            SerializedProperty format = nameFormatList.GetArrayElementAtIndex(i);
                            string             name   = nameList.GetArrayElementAtIndex(i).stringValue;
                            GUI.color = compareDescription(name, format.stringValue) ? Color.grey : Color.white;
                            EditorGUILayout.PropertyField(format, GUIContent.none, GUILayout.ExpandWidth(true), GUILayout.Height(EditorGUIUtility.singleLineHeight));
                            InsertPlaceHolder(format.stringValue, new GUIContent("... Rich Text Format"));
                            GUI.color = Color.white;
                        }
                    }
                    GUILayout.EndVertical();

                    GUILayout.BeginVertical(GUILayout.Width(20));
                    {
                        if (GUILayout.Button("+", "box", GUILayout.Width(20)))
                        {
                            Undo.RecordObject(serializedObject.targetObject, "ChangeArraySize");
                            nameList.arraySize++;
                            nameFormatList.arraySize++;
                        }
                        for (int i = 0; i < nameList.arraySize; i++)
                        {
                            if (GUILayout.Button("x", EditorStyles.miniButton, GUILayout.Width(20), GUILayout.Height(EditorGUIUtility.singleLineHeight)))
                            {
                                Undo.RecordObject(serializedObject.targetObject, "RemoveElement");
                                nameList.DeleteArrayElementAtIndex(i);
                                nameFormatList.DeleteArrayElementAtIndex(i);
                                i--;
                            }
                        }
                    }
                    GUILayout.EndVertical();
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndVertical();
        }