Ejemplo n.º 1
0
    private void OnGUI()
    {
        DisplayMergeItem(ref first, "Select first data");
        DisplayMergeItem(ref second, "Select second data");

        LocalizationEditorUtils.DrawDivider();

        bool disabled = string.IsNullOrEmpty(first.path) || string.IsNullOrEmpty(second.path);

        EditorGUI.BeginDisabledGroup(disabled);

        if (GUILayout.Button("Merge"))
        {
            MergeFiles();
        }

        if (disabled)
        {
            EditorGUI.EndDisabledGroup();
        }
    }
Ejemplo n.º 2
0
    private void DisplayDataFields()
    {
        filter = EditorGUILayout.TextField("Search", filter, GUILayout.ExpandWidth(true));

        GUILayout.Space(20);
        EditorGUILayout.LabelField(new GUIContent {
            text = "<b>Data : </b>"
        }, new GUIStyle {
            fontSize = 20, richText = true
        });
        GUILayout.Space(10);


        scrollView = EditorGUILayout.BeginScrollView(scrollView);
        SerializedObject   serializedObject         = new SerializedObject(this);
        SerializedProperty keyValuePairListProperty = serializedObject.FindProperty("data.keyValuePairs");

        for (int i = 0; i < keyValuePairListProperty.arraySize; i++)
        {
            var keyValuePairProp = keyValuePairListProperty.GetArrayElementAtIndex(i);
            var keyProp          = keyValuePairProp.FindPropertyRelative("key");
            var valueProp        = keyValuePairProp.FindPropertyRelative("value");
            if (filter == "" || keyProp.stringValue.StartsWith(filter))
            {
                if (EditorGUILayout.PropertyField(keyValuePairProp))
                {
                    EditorGUI.BeginChangeCheck();

                    EditorGUILayout.PropertyField(keyProp);
                    EditorGUILayout.PropertyField(valueProp, GUILayout.MinHeight(100.0f));

                    if (EditorGUI.EndChangeCheck())
                    {
                        saved = false;
                    }
                }

                LocalizationEditorUtils.DrawDivider();

                GUILayout.Space(10.0f);
            }
        }
        serializedObject.ApplyModifiedProperties();
        EditorGUILayout.EndScrollView();

        EditorGUILayout.Separator();

        if (GUILayout.Button("Add Pair"))
        {
            data.keyValuePairs.Add(new KeyValuePair());
        }

        GUILayout.Space(20.0f);

        EditorGUI.BeginDisabledGroup(saved);
        if (filePath != null && (GUILayout.Button("Save File") || (EditorGUI.actionKey && sPressed)))
        {
            LocalizationEditorUtils.SaveDataToSetPath(filePath, data);
            saved = true;
            Repaint();
        }
        EditorGUI.EndDisabledGroup();

        if (GUILayout.Button("Save File As..."))
        {
            SaveData();
        }

        if (GUILayout.Button("Sort"))
        {
            SortData();
        }
    }