Esempio n. 1
0
    public override void OnInspectorGUI()
    {
        EditorGUI.BeginChangeCheck();

        serializedObject.Update();

        SerializedProperty iterator = serializedObject.GetIterator();

        LocalizedText text = target as LocalizedText;

        if (text != null)
        {
            if (this.zhString != text.GetText())
            {
                this.zhString = text.GetText();
            }
            text.SerializeZhText(this.zhString);
        }

        for (bool enterChildren = true; iterator.NextVisible(enterChildren); enterChildren = false)
        {
            if (iterator.name == "m_zhText")
            {
                EditorGUILayout.LabelField("zhText", iterator.stringValue, new GUILayoutOption[0]);
            }
            else if (iterator.name == "m_key")
            {
                EditorGUILayout.PropertyField(iterator, true, new GUILayoutOption[0]);
                string key             = iterator.stringValue;
                string localizedString = LocalizationImporter.GetLanguages(key);
                if (string.IsNullOrEmpty(zhString))
                {
                    zhString = localizedString;
                }
                EditorGUILayout.LabelField("中文", localizedString, new GUILayoutOption[0]);
                if (!string.IsNullOrEmpty(zhString) && zhString != localizedString)
                {
                    DrawValuesAutoComplete(iterator, zhString);
                }
            }
        }

        serializedObject.ApplyModifiedProperties();

        if (EditorGUI.EndChangeCheck())
        {
            if (text != null)
            {
                text.OnLocalize();
            }
        }
    }