Exemplo n.º 1
0
    protected void DrawRecord(int recordIndex, out bool recordRemoved)
    {
        recordRemoved = false;
        PrefsRecord record = filteredRecords[recordIndex];

        CustomEditorGUI.Separator();

        using (CustomEditorGUI.Horizontal(CustomEditorGUI.PanelWithBackground))
        {
            if (GUILayout.Button(new GUIContent("X", "Delete this pref."), CustomEditorGUI.CompactButton, GUILayout.Width(20)))
            {
                record.Delete();
                allRecords.Remove(record);
                filteredRecords.Remove(record);
                recordRemoved = true;
                return;
            }

            GUI.enabled = record.dirtyValue || record.dirtyKey && record.prefType != PrefsRecord.PrefsType.Unknown;
            if (GUILayout.Button(new GUIContent("S", "Save changes in this pref."), CustomEditorGUI.CompactButton, GUILayout.Width(20)))
            {
                record.Save();
                GUIUtility.keyboardControl = 0;
            }
            GUI.enabled = true;

            GUI.enabled = record.prefType != PrefsRecord.PrefsType.Unknown;

            GUI.enabled = true;

            if (GUILayout.Button(new GUIContent("...", "Other operations"), CustomEditorGUI.CompactButton, GUILayout.Width(25)))
            {
                ShowOtherMenu(record);
            }

            Color guiColor = GUI.color;

            GUI.enabled = record.prefType != PrefsRecord.PrefsType.Unknown;

            record.Key = EditorGUILayout.TextField(record.Key, GUILayout.MaxWidth(200), GUILayout.MinWidth(50));

            if (record.prefType == PrefsRecord.PrefsType.String)
            {
                // to avoid TextMeshGenerator error because of too much characters
                if (record.StringValue.Length > 16382)
                {
                    GUI.enabled = false;
                    EditorGUILayout.TextField(STRING_TOO_LONG, GUILayout.MinWidth(150));
                    GUI.enabled = record.prefType != PrefsRecord.PrefsType.Unknown;
                }
                else
                {
                    record.StringValue = EditorGUILayout.TextField(record.StringValue, GUILayout.MinWidth(150));
                }
            }
            else if (record.prefType == PrefsRecord.PrefsType.Int)
            {
                record.IntValue = EditorGUILayout.IntField(record.IntValue, GUILayout.MinWidth(150));
            }
            else if (record.prefType == PrefsRecord.PrefsType.Float)
            {
                record.FloatValue = EditorGUILayout.FloatField(record.FloatValue, GUILayout.MinWidth(150));
            }
            else
            {
                GUI.enabled = false;
                EditorGUILayout.TextField(UNKNOWN_VALUE_DESCRIPTION, GUILayout.MinWidth(150));
                GUI.enabled = record.prefType != PrefsRecord.PrefsType.Unknown;
            }
            GUI.color   = guiColor;
            GUI.enabled = true;

            EditorGUILayout.LabelField(record.DisplayType, GUILayout.Width(70));
        }
    }