public override void OnInspectorGUI()
        {
            Init();

            serializedObject.Update();

            GUI.changed = false;
            EditorGUILayout.PropertyField(m_M10NDB);
            if (GUI.changed)
            {
                MultiLangStringDatabase db = m_M10NDB.objectReferenceValue as MultiLangStringDatabase;
                if (db != null)
                {
                    m_M10NIndex.intValue = db.IndexOfKey(m_M10NSelectedKey.stringValue);
                }

                StringTableEditorWindow.RepaintEditor();
            }

            DoM10NStringReferenceGUI();

            EditorGUILayout.PropertyField(m_FontData);
            AppearanceControlsGUI();
            RaycastControlsGUI();
            serializedObject.ApplyModifiedProperties();
        }
    void OnGUI()
    {
        db          = (MultiLangStringDatabase)EditorGUILayout.ObjectField("Database", db, typeof(MultiLangStringDatabase));
        parseScenes = EditorGUILayout.Toggle("Scenes", parseScenes);

        using (new EditorGUI.DisabledScope(db == null))
        {
            if (GUILayout.Button("Start"))
            {
                keys = new Dictionary <string, HashSet <string> > ();

                if (parseScenes)
                {
                    IterateScenes();
                }
            }
        }

        if (keys != null && keys.Count > 0)
        {
            foreach (var key in keys)
            {
                foreach (var c in key.Value)
                {
                    EditorGUILayout.LabelField("#: " + c);
                }
                EditorGUILayout.LabelField(key.Key);
                EditorGUILayout.Space();
            }
        }
    }
예제 #3
0
        private static void SaveLangDBFileAtPath(MultiLangStringDatabase db, string storeFilePath)
        {
            storeFilePath = Path.ChangeExtension(storeFilePath, ".asset");
            var absoluteFilePath = GetAbsoluteFilePath(storeFilePath);

            storeFilePath = Path.Combine("Assets", storeFilePath);
            if (File.Exists(absoluteFilePath))
            { // update existing asset
                var existingDb = AssetDatabase.LoadMainAssetAtPath(storeFilePath) as MultiLangStringDatabase;
                EditorUtility.CopySerialized(db, existingDb);
                AssetDatabase.SaveAssets();
            }
            else
            { // create new asset
                (new FileInfo(absoluteFilePath)).Directory.Create();
                AssetDatabase.Refresh();
                AssetDatabase.CreateAsset(db, storeFilePath);
            }
        }
        private void DoM10NStringReferenceGUI()
        {
            MultiLangStringDatabase db = m_M10NDB.objectReferenceValue as MultiLangStringDatabase;

            //select the language you want to display
            EditorGUILayout.LabelField("Key", EditorStyles.boldLabel);

            EditorGUILayout.BeginHorizontal();

            float vspace = EditorGUIUtility.standardVerticalSpacing;
            float lineH  = EditorGUIUtility.singleLineHeight;

            GUILayoutUtility.GetRect(vspace, vspace, lineH, lineH);

            m_keyGUI.OnKeyGUI(db, m_M10NSelectedKey.stringValue);

            EditorGUILayout.EndHorizontal();

            if (keyMissing)
            {
                EditorGUILayout.LabelField("Key was:" + m_M10NSelectedKey.stringValue);
                if (GUILayout.Button("Add key to current database"))
                {
                    db.AddTextEntry(m_M10NSelectedKey.stringValue);
                    m_M10NIndex.intValue = db.IndexOfKey(m_M10NSelectedKey.stringValue);
                    EditorUtility.SetDirty(db);
                }
            }

            GUILayoutUtility.GetRect(vspace, vspace, lineH, lineH);

            EditorGUILayout.LabelField("Text", EditorStyles.boldLabel);
            if (db != null && !keyMissing)
            {
                EditorGUILayout.BeginHorizontal();
                GUILayoutUtility.GetRect(vspace, vspace, lineH, lineH);
                GUILayout.TextArea(db.current.values[m_M10NIndex.intValue].text, GUILayout.Height(60));
                //EditorGUILayout.LabelField(db.current.values[m_M10NIndex.intValue].text);
                EditorGUILayout.EndHorizontal();
            }
        }