Beispiel #1
0
            public string Apply(DTextSource textSource, string input)
            {
                if (string.IsNullOrEmpty(code) || string.IsNullOrWhiteSpace(code))
                {
                    return(input);
                }

                string finalResult;

                if (SpecialResults.ContainsKey(result))
                {
                    finalResult = SpecialResults[result]();
                }
                else
                {
                    if (textSource != null)
                    {
                        finalResult = textSource.GetLocalText(result);
                    }
                    else
                    {
                        finalResult = DLocalizationManager.Instance.GetLocalText(result);
                    }
                }
                return(input.Replace(code, finalResult));
            }
Beispiel #2
0
        public override void OnInspectorGUI()
        {
            Color       errorColor = new Color32(0xFF, 0xBA, 0xBE, 0xFF);
            DTextSource source     = target as DTextSource;

            using (new EditorGUI.DisabledGroupScope(true))
            {
                MonoScript script = MonoScript.FromMonoBehaviour(source);
                script = EditorGUILayout.ObjectField("Script", script, typeof(MonoScript), false) as MonoScript;
            }

            if (string.IsNullOrEmpty(source.resource))
            {
                UnityEngine.GUI.backgroundColor = errorColor;
                source.resource = EditorGUILayout.TextField("XML-ресурс", source.resource);
                UnityEngine.GUI.backgroundColor = Color.white;
            }
            else
            {
                source.resource = EditorGUILayout.TextField("XML-ресурс", source.resource);

                if (GUILayout.Button("Инициализировать", GUILayout.ExpandWidth(true), GUILayout.Height(20f)))
                {
                    source.Init();
                }
                EditorGUILayout.Separator();

                if (source.languageCodes != null && source.languageCodes.Count > 0)
                {
                    source.runtimeLanguageDefinition = EditorGUILayout.Toggle("Системный язык?", source.runtimeLanguageDefinition);

                    if (!source.runtimeLanguageDefinition)
                    {
                        int selected = Mathf.Max(0, source.languageCodes.IndexOf(source.language));
                        selected        = EditorGUILayout.Popup("Язык", selected, source.languageCodes.ToArray());
                        source.language = source.languageCodes[selected];
                    }
                }
            }
        }