Exemple #1
0
        public virtual void DrawTestingGUI()
        {
            if (!EditorApplication.isPlaying)
            {
                LocalizationEditor.GetLanguages();
                if (LocalizationEditor.Keys.Count != 0 && LocalizationEditor.Languages.Count != 0)
                {
                    GUILayout.Space(10);
                    GUILayout.Label("Localization Testing", EditorStyles.boldLabel);
                    var index = Mathf.Max(0, LocalizationEditor.Languages.FindIndex(lang => _myLoc.LanguageOverride == lang.Name));

                    EditorGUI.BeginChangeCheck();
                    var overrideLang = LocalizationEditor.Languages[EditorGUILayout.Popup("Language Override", index, LocalizationEditor.Languages.Select(lang => lang.EnglishName).ToArray())].Name;
                    if (EditorGUI.EndChangeCheck())
                    {
                        Undo.RecordObject(_myLoc, "Localization Override Change");
                        _myLoc.LanguageOverride = overrideLang;
                    }
                    if (GUILayout.Button("Localize Text"))
                    {
                        Undo.RecordObject(_myLoc.GetComponent <Text>(), "Localization Override Change");
                        _myLoc.gameObject.SetActive(false);
                        _myLoc.Set();
                        _myLoc.gameObject.SetActive(true);
                    }
                }
            }
        }
Exemple #2
0
        public static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            var assets = importedAssets.ToList();

            assets.AddRange(deletedAssets);
            assets.AddRange(movedAssets);
            assets.AddRange(movedFromAssetPaths);

            if (assets.Any(a => a.Contains("/Resources/Localization")))
            {
                LocalizationEditor.GetKeys(true);
            }
        }
        public override void OnInspectorGUI()
        {
            LocalizationEditor.GetKeys();

            /*var index = LocalizationEditor.Keys.IndexOf(((TextLocalization)_myLoc).Key);
             * if (LocalizationEditor.Keys.Count == 0)
             * {
             *      GUILayout.Label("No Keys Found", EditorStyles.boldLabel);
             * }
             * else
             * {
             *      ((TextLocalization)_myLoc).Key = index >= 0 ? LocalizationEditor.Keys[EditorGUILayout.Popup("Key", index, LocalizationEditor.Keys.ToArray())] : EditorGUILayout.TextField("Key", ((TextLocalization)_myLoc).Key);
             *      ((TextLocalization)_myLoc).ToUpper = EditorGUILayout.Toggle("Upper Case", ((TextLocalization)_myLoc).ToUpper);
             * }*/
            DrawDefaultInspector();
            DrawTestingGUI();
        }