Beispiel #1
0
        void DrawAddNewKey(LELocalize leLocalize)
        {
            newKey = EditorGUILayout.TextField(LEConstants.KeyLbl, newKey);
            if (!string.IsNullOrEmpty(newKey) && GUILayout.Button(LEConstants.AddStringBtn))
            {
                LEStringTableEditor.AddNewString(newKey, leLocalize.Text);
                LEStringTableEditor.Save();

                leLocalize.localized_string_key = newKey;
                nextState = LELocalizeState.Initialized;
            }
        }
        void DrawNewLocStringField()
        {
            if (isRTL)
            {
                DrawVisualPresentation(newLocKey.Equals(LEConstants.NewKeyLbl)?string.Empty:newLocKey,
                                       newLocValue.Equals(LEConstants.NewValueLbl)?string.Empty:newLocValue);
            }

            // Key label position
            newLocKey = string.IsNullOrEmpty(newLocKey) ? LEConstants.NewKeyLbl : newLocKey;
            Rect labelPosition = GetResizableTextBoxPosition(newLocKey, boxWidth, keyStyle);

            // Key box
            GUI.Box(labelPosition, string.Empty);

            // Key label
            newLocKey = DrawResizableTextBox(newLocKey, labelPosition, keyStyle);

            // Value label position
            newLocValue = string.IsNullOrEmpty(newLocValue)? LEConstants.NewValueLbl : newLocValue;
            Rect valuePosition = GetResizableTextBoxPosition(newLocValue, boxWidth, valueStyle);

            // Value box
            GUI.Box(valuePosition, string.Empty);

            // Value label
            newLocValue = DrawResizableTextBox(newLocValue, valuePosition, valueStyle);

            // Add String Button
            content.text = LEConstants.AddStringBtn;
            size         = GUI.skin.button.CalcSize(content);
            if (GUI.Button(new Rect(drawHelper.CurrentLinePosition, drawHelper.TopOfLine(), size.x, size.y), content) && !string.IsNullOrEmpty(newLocKey) && !string.IsNullOrEmpty(newLocValue))
            {
                try
                {
                    LEStringTableEditor.AddNewString(newLocKey, newLocValue);

                    newLocKey   = string.Empty;
                    newLocValue = string.Empty;

                    GUI.FocusControl(string.Empty);
                }
                catch (Exception ex)
                {
                    Debug.LogException(ex);
                }
            }

            float height = Math.Max(labelPosition.height, valuePosition.height);

            drawHelper.NewLine(height / drawHelper.LineHeight - 1);
        }
        static bool ProcessGameObject(GameObject go, string value)
        {
            bool result = false;

            // Determine if this component already has a LELocalize attached
            if (go.GetComponent <LELocalize>() == null)
            {
                // Add LELocalize
                LELocalize leLocalize = go.AddComponent <LELocalize>();

                string key = LEConstants.AutoIndexPrefix + LESettings.Instance.AutoIndex++;
                LEStringTableEditor.AddNewString(key, value);

                leLocalize.State = LELocalizeState.Initialized;
                leLocalize.localized_string_key = key;

                result = true;
            }

            return(result);
        }