Exemple #1
0
        private void ShowLocalizeValues(UILocalizationKeys myTarget, int index)
        {
            string searchValue = myTarget.Keys[index].ToLower();

            const int maxCount = 5;
            Dictionary <string, int> helpKeys = new Dictionary <string, int>(maxCount);

            for (int i = 0; i < searchKeys.Length; i++)
            {
                string key = searchKeys[i];
                if (key == searchValue)
                {
                    return;
                }
                if (key.Contains(searchValue))
                {
                    helpKeys.Add(key, i);
                    if (helpKeys.Count == maxCount)
                    {
                        break;
                    }
                }
            }
            if (helpKeys.Count == 0)
            {
                return;
            }

            EditorGUILayout.Space();

            var color = GUI.backgroundColor;

            GUI.backgroundColor = Color.green;

            foreach (KeyValuePair <string, int> kvp in helpKeys)
            {
                if (GUILayout.Button(kvp.Key))
                {
                    myTarget.Keys[index] = localizationKeys[kvp.Value];
                    UpdateValue(myTarget);
                    GUI.FocusControl(string.Empty);
                }
            }
            GUI.backgroundColor = color;
        }
Exemple #2
0
        private void UpdateValue(UILocalizationKeys myTarget)
        {
            var result = new string[myTarget.Keys.Length];

            for (var index = 0; index < myTarget.Keys.Length; index++)
            {
                var myTargetKey = myTarget.Keys[index];
                int keyIndex    = GetIdByKey(myTargetKey, searchKeys);
                if (keyIndex != -1)
                {
                    result[index] = localizationValues[keyIndex];

                    myTarget.Keys[index] = localizationKeys[keyIndex];
                }
                else
                {
                    result[index] = "";
                }
            }

            myTarget.SetEditorValue(result);
        }