public override void OnInspectorGUI()
    {
        if (editorType == EditorType.SINGLE_ASSET)
        {
            localizedText.isExpandedGlobal = true;
        }

        // Update the state of the serializedObject to the current values of the target.
        serializedObject.Update();

        // Global GUI Box
        GUILayout.BeginVertical(GUI.skin.box);

        EditorColors.SET_SUBTITLE2_COLOR();
        GUILayout.BeginHorizontal(GUI.skin.box);
        GUILayout.BeginHorizontal(EditorStyles.inspectorDefaultMargins);

        GUIStyle myFoldoutStyle = new GUIStyle(EditorStyles.foldout);

        myFoldoutStyle.fontStyle    = FontStyle.Bold;
        myFoldoutStyle.fontSize     = 11;
        myFoldoutStyle.fixedHeight  = 16f;
        myFoldoutStyle.stretchWidth = true;

        // Global Foldout
        localizedText.isExpandedGlobal = EditorGUILayout.Foldout(localizedText.isExpandedGlobal, new GUIContent(localizedText.name), true, myFoldoutStyle);

        // Show remove button only in case that this LocalizedText belongs to one LocalizedTextsGroup
        if (editorType == EditorType.ALL_ASSETS)
        {
            // Display a button showing a '-' that if clicked removes this item from the group.
            if (EditorTools.createListButton(" - ", true))
            {
                removeLocalizedText();
                return;
            }
        }

        GUILayout.EndHorizontal();
        GUILayout.EndHorizontal();
        EditorColors.SET_DEFAULT_COLOR();

        if (localizedText.isExpandedGlobal)
        {
            expandedGUI();
        }

        GUILayout.EndVertical();

        // Push data back from the serializedObject to the target.
        serializedObject.ApplyModifiedProperties();
    }
 private void setFoldoutDefaultColor(int index, ref GUIStyle myFoldoutStyle, ref string defaultText)
 {
     if (AllGameLanguages.Instance.gameLanguagesList[index].isDefault)
     {
         GUI.color = Color.yellow;
         myFoldoutStyle.fontStyle = FontStyle.Bold;
         defaultText = " [DEFAULT]";
     }
     else
     {
         EditorColors.SET_DEFAULT_COLOR();
         myFoldoutStyle.fontStyle = FontStyle.Normal;
         defaultText = "";
     }
 }
Example #3
0
        public static void createTitleBox(string title, bool subTitle = false)
        {
            if (subTitle)
            {
                EditorColors.SET_SUBTITLE_COLOR();
            }
            else
            {
                EditorColors.SET_MAINTITLE_COLOR();
            }

            GUILayout.BeginVertical(GUI.skin.box);

            EditorGUILayout.LabelField(title, EditorStyles.boldLabel);

            GUILayout.EndVertical();
            EditorColors.SET_DEFAULT_COLOR();
        }
    private void createGameLanguagesBoxes()
    {
        GUIStyle myFoldoutStyle = new GUIStyle(EditorStyles.foldout);
        string   defaultText    = "";

        for (int i = 0; i < allLanguages.gameLanguagesList.Count; i++)
        {
            setFoldoutDefaultColor(i, ref myFoldoutStyle, ref defaultText);

            EditorGUILayout.BeginVertical(GUI.skin.box);

            EditorGUILayout.BeginHorizontal(EditorStyles.inspectorDefaultMargins);

            isExpanded[i] = EditorGUILayout.Foldout(isExpanded[i], allLanguages.gameLanguagesList[i].gameLanguage.code + " - " + allLanguages.gameLanguagesList[i].gameLanguage.name + defaultText, true, myFoldoutStyle);

            EditorColors.SET_DEFAULT_COLOR();

            allLanguages.gameLanguagesList[i].isDefault = EditorGUILayout.Toggle(allLanguages.gameLanguagesList[i].isDefault, GUILayout.Width(30));

            if (allLanguages.gameLanguagesList[i].isDefault)
            {
                allLanguages.setDefaultLanguage(i);
            }

            CreateRemoveButton(i);

            EditorGUILayout.EndHorizontal();

            // If the foldout is open show the expanded GUI.
            if (isExpanded[i])
            {
                ExpandedGUI(allLanguages.gameLanguagesList[i]);
            }

            EditorGUILayout.EndVertical();
        }

        allLanguages.checkDefaultLanguage();
    }
    private void createISOLanguagesBox()
    {
        EditorGUILayout.BeginVertical(GUI.skin.box);
        EditorGUILayout.LabelField("ISO Languages", EditorStyles.boldLabel);
        EditorGUILayout.BeginHorizontal(EditorStyles.inspectorDefaultMargins);

        if (fileISOLanguages != null)
        {
            // Create the options for all iso languages stored in memory
            string[] isoLanguageOptions = new string[fileISOLanguages.Length];
            string   prefix             = "";

            // If the json items in the file are sorted by code, then they will be already sorted for popup submenus
            // so we can use the first char of the language code to order them.
            for (int i = 0; i < isoLanguageOptions.Length; i++)
            {
                prefix = fileISOLanguages[i].code[0] + "/";
                isoLanguageOptions[i] = prefix + fileISOLanguages[i].code + " - " + fileISOLanguages[i].name + " - " + fileISOLanguages[i].nativeName;
            }

            string label = "File Languages";
            EditorGUILayout.LabelField(label, GUILayout.Width((label.Length * 7)));
            ISOListSelectedIndex = EditorGUILayout.Popup(ISOListSelectedIndex, isoLanguageOptions);

            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal(EditorStyles.inspectorDefaultMargins);

            EditorColors.SET_ADD_BUTTON_COLOR();
            if (GUILayout.Button(" Add Selected Language to Game ", GUILayout.ExpandWidth(true)))
            {
                AddLanguage(fileISOLanguages[ISOListSelectedIndex]);
            }
            EditorColors.SET_DEFAULT_COLOR();
        }

        EditorGUILayout.EndHorizontal();
        EditorGUILayout.EndVertical();
    }
Example #6
0
        public static bool createListButton(string title, bool removeButton = false, GUILayoutOption option = null)
        {
            if (removeButton)
            {
                EditorColors.SET_REMOVE_BUTTON_COLOR();
            }
            else
            {
                EditorColors.SET_ADD_BUTTON_COLOR();
            }

            if (option == null)
            {
                option = GUILayout.ExpandWidth(false);
            }

            bool pressed = GUILayout.Button(title, option);

            EditorColors.SET_DEFAULT_COLOR();

            return(pressed);
        }
    private void createLocalizedTextsListGUIBOXES()
    {
        EditorTools.createTitleBox("Localized Texts", true);

        GUIStyle myFoldoutStyle = new GUIStyle(EditorStyles.miniButton);
        string   defaultText    = "";

        myFoldoutStyle.fixedWidth = 35f;

        for (int i = 0; i < localizedText.localizedTextsList.Count; i++)
        {
            //AllGameLanguagesEditor.setFoldoutDefaultColor(i, ref myFoldoutStyle, ref defaultText);

            GUILayout.BeginVertical(GUI.skin.box);

            GUILayout.BeginHorizontal(EditorStyles.inspectorDefaultMargins);

            string LanguageKey = localizedText.localizedTextsList[i].languageInfo.code;

            // Handle foldut through isExpanded variable
            localizedText.isExpandedLocalText[i] = EditorGUILayout.Foldout(localizedText.isExpandedLocalText[i], new GUIContent(LanguageKey + defaultText), true, myFoldoutStyle);

            if (localizedText.localizedTextsList[i].getText() == "")
            {
                EditorGUILayout.LabelField(new GUIContent("Empty Text", EditorGUIUtility.IconContent("console.warnicon.sml").image), EditorStyles.boldLabel, GUILayout.ExpandWidth(false));
            }
            else
            {
                EditorGUILayout.LabelField(new GUIContent("OK", EditorGUIUtility.IconContent("Collab").image), EditorStyles.boldLabel, GUILayout.ExpandWidth(false));
            }

            GUILayout.EndHorizontal();

            EditorColors.SET_DEFAULT_COLOR();


            if (localizedText.isExpandedLocalText[i])
            {
                string lText = localizedText.localizedTextsList[i].getText();

                float minWidth, maxWidth;

                GUI.skin.label.CalcMinMaxWidth(new GUIContent(lText), out minWidth, out maxWidth);
                float currentViewWidth = EditorGUIUtility.currentViewWidth;

                int numLines = (int)Math.Round(maxWidth / currentViewWidth + 1) + lText.Split('\n').Length - 1;
                lText = EditorGUILayout.TextArea(lText, EditorStyles.textArea, GUILayout.Height(EditorGUIUtility.singleLineHeight * numLines));

                localizedText.localizedTextsList[i].setText(lText);

                GUILayout.Space(2.5f);
            }

            GUILayout.EndVertical();

            if (i != localizedText.localizedTextsList.Count - 1 &&
                editorType == EditorType.SINGLE_ASSET)
            {
                EditorTools.createHorizontalSeparator();
            }
        }
    }