Пример #1
0
        void OnEnable()
        {
            mLocalize                    = (Localize)target;
            mProp_mTerm                  = serializedObject.FindProperty("mTerm");
            mProp_mTermSecondary         = serializedObject.FindProperty("mTermSecondary");
            mProp_TranslatedObjects      = serializedObject.FindProperty("TranslatedObjects");
            mProp_IgnoreRTL              = serializedObject.FindProperty("IgnoreRTL");
            mProp_SeparateWords          = serializedObject.FindProperty("AddSpacesToJoinedLanguages");
            mProp_MaxCharactersInRTL     = serializedObject.FindProperty("MaxCharactersInRTL");
            mProp_IgnoreNumbersInRTL     = serializedObject.FindProperty("IgnoreNumbersInRTL");
            mProp_CorrectAlignmentForRTL = serializedObject.FindProperty("CorrectAlignmentForRTL");
            mProp_LocalizeOnAwake        = serializedObject.FindProperty("LocalizeOnAwake");
            mProp_AlwaysForceLocalize    = serializedObject.FindProperty("AlwaysForceLocalize");
            mProp_TermSuffix             = serializedObject.FindProperty("TermSuffix");
            mProp_TermPrefix             = serializedObject.FindProperty("TermPrefix");

            // Check Copy/Paste Localize component into another gameObject
            if (mLocalize.mTarget != null)
            {
                var cmp = mLocalize.mTarget as Component;
                if (cmp != null && cmp.gameObject != mLocalize.gameObject)
                {
                    serializedObject.ApplyModifiedProperties();
                    mLocalize.ReleaseTarget();
                    serializedObject.Update();
                }
            }

            if (LocalizationManager.Sources.Count == 0)
            {
                LocalizationManager.UpdateSources();
            }
            //LocalizationEditor.ParseTerms (true);

            //mGUI_ShowReferences = (mLocalize.TranslatedObjects!=null && mLocalize.TranslatedObjects.Length>0);
            //mGUI_ShowCallback = (mLocalize.LocalizeCallBack.Target!=null);
            //mGUI_ShowTems = true;
            LocalizationEditor.mKeysDesc_AllowEdit = false;
            GUI_SelectedTerm = 0;
            mNewKeyName      = mLocalize.Term;

            if (mLocalize.Source != null)
            {
                LocalizationEditor.mLanguageSource = mLocalize.Source;
            }
            else
            {
                if (LocalizationManager.Sources.Count == 0)
                {
                    LocalizationManager.UpdateSources();
                }
                LocalizationEditor.mLanguageSource = LocalizationManager.GetSourceContaining(mLocalize.Term);
            }

            //UpgradeManager.EnablePlugins();
            LocalizationEditor.ApplyInferredTerm(mLocalize);
        }
Пример #2
0
        void OnGUI_Target()
        {
            List <string> TargetTypes   = new List <string>();
            int           CurrentTarget = -1;

            mLocalize.FindTarget();
            foreach (var locTarget in LocalizationManager.mLocalizeTargets)
            {
                if (locTarget.CanLocalize(mLocalize))
                {
                    TargetTypes.Add(locTarget.GetName());

                    if (locTarget.HasTarget(mLocalize))
                    {
                        CurrentTarget = TargetTypes.Count - 1;
                    }
                }
            }

            if (CurrentTarget == -1)
            {
                CurrentTarget = TargetTypes.Count;
                TargetTypes.Add("None");
            }

            GUILayout.BeginHorizontal();
            GUILayout.Label("Target:", GUILayout.Width(60));
            GUI.changed = false;
            int index = EditorGUILayout.Popup(CurrentTarget, TargetTypes.ToArray());

            if (GUI.changed)
            {
                serializedObject.ApplyModifiedProperties();
                mLocalize.ReleaseTarget();

                foreach (var locTarget in LocalizationManager.mLocalizeTargets)
                {
                    if (locTarget.GetName() == TargetTypes[index])
                    {
                        locTarget.FindTarget(mLocalize);
                        break;
                    }
                }
                serializedObject.Update();
            }
            GUILayout.EndHorizontal();
        }