Exemplo n.º 1
0
        protected override void DrawInspector()
        {
            base.DrawInspector();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            {
                EditorGUILayout.LabelField("Audio Clips", HeaderStyle);
                EditorGUILayout.BeginHorizontal(GUI.skin.box);
                {
                    _searchBar.Draw();

                    if (GUILayout.Button("Add clip"))
                    {
                        RecordObject("Music Storage Change");
                        Target.AudioClips.Add(new AudioClipConfig());
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();

            var clipsList = serializedObject.FindProperty("AudioClips");
            var count     = clipsList.arraySize;

            if (count > 0)
            {
                EditorGUILayout.BeginVertical(GUI.skin.box);
                {
                    int searchResultsCount = 0;
                    for (int i = 0; i < count; i++)
                    {
                        var element   = clipsList.GetArrayElementAtIndex(i);
                        var key       = element.FindPropertyRelative("Key");
                        var audioClip = element.FindPropertyRelative("AudioClip");
                        var capacity  = element.FindPropertyRelative("Capacity");

                        if (!_searchBar.IsEmpty && !_searchBar.IsMatchingTheFilter(key.stringValue))
                        {
                            continue;
                        }

                        searchResultsCount++;
                        EditorGUILayout.BeginHorizontal(GUI.skin.box);
                        {
                            EditorGUILayout.BeginVertical();
                            {
                                EditorGUILayout.PropertyField(key);
                                EditorGUILayout.PropertyField(audioClip);
                                EditorGUILayout.PropertyField(capacity);
                            }
                            EditorGUILayout.EndVertical();

                            if (GUILayout.Button("X", GUILayout.Width(20)))
                            {
                                RecordObject("Music Storage Change");
                                Target.AudioClips.RemoveAt(i);
                            }
                        }
                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.Space();
                    }

                    if (searchResultsCount == 0)
                    {
                        EditorGUILayout.LabelField("No matches found...", LabelStyle);
                    }
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.Space();
        }
Exemplo n.º 2
0
        protected override void DrawInspector()
        {
            base.DrawInspector();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            {
                EditorGUILayout.LabelField("Signals Storage", HeaderStyle);
                EditorGUILayout.BeginHorizontal(GUI.skin.box);
                {
                    _searchBar.Draw();

                    if (GUILayout.Button("Add Signal"))
                    {
                        RecordObject("Signals Storage Change");
                        Target.Signals.Add(string.Empty);
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();

            var signals = serializedObject.FindProperty("Signals");
            var count   = signals.arraySize;

            if (count > 0)
            {
                EditorGUILayout.BeginVertical(GUI.skin.box);
                {
                    int searchResultsCount = 0;
                    for (int i = 0; i < count; i++)
                    {
                        var element = signals.GetArrayElementAtIndex(i);

                        if (!_searchBar.IsEmpty && !_searchBar.IsMatchingTheFilter(element.stringValue))
                        {
                            continue;
                        }

                        searchResultsCount++;
                        EditorGUILayout.BeginHorizontal(GUI.skin.box);
                        {
                            EditorGUILayout.BeginVertical();
                            {
                                EditorGUILayout.PropertyField(element, new GUIContent(string.Format("Signal {0}", i + 1)));
                            }
                            EditorGUILayout.EndVertical();

                            if (GUILayout.Button("X", GUILayout.Width(20)))
                            {
                                RecordObject("Signals Storage Change");
                                Target.Signals.RemoveAt(i);
                            }
                        }
                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.Space();
                    }

                    if (searchResultsCount == 0)
                    {
                        EditorGUILayout.LabelField("No matches found...", LabelStyle);
                    }
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.Space();
        }
Exemplo n.º 3
0
        private void DrawDictionaryEditor()
        {
            if (Target.LanguagesData.Count == 0)
            {
                EditorGUILayout.BeginVertical(GUI.skin.box);
                {
                    EditorGUILayout.LabelField("Add new Language using \"Languages\" tab.");
                }
                EditorGUILayout.EndVertical();

                return;
            }

            if (LangIndex >= Target.LanguagesData.Count)
            {
                LangIndex = 0;
            }

            EditorGUILayout.BeginHorizontal(GUI.skin.box);
            {
                if (GUILayout.Button("<-", GUILayout.MaxWidth(100f)))
                {
                    LangIndex--;
                    if (LangIndex < 0)
                    {
                        LangIndex = Target.LanguagesData.Count - 1;
                    }
                }

                var label          = string.Format("{0}. {1}", LangIndex + 1, Target.LanguagesData[LangIndex].Language.ToString());
                var subHeaderStyle = new GUIStyle(GUI.skin.label)
                {
                    normal    = { textColor = Color.gray },
                    alignment = TextAnchor.MiddleCenter,
                    fontStyle = FontStyle.Italic
                };

                EditorGUILayout.LabelField(label, subHeaderStyle);

                if (GUILayout.Button("->", GUILayout.MaxWidth(100f)))
                {
                    LangIndex++;
                    if (LangIndex >= Target.LanguagesData.Count)
                    {
                        LangIndex = 0;
                    }
                }
            }
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical(GUI.skin.box);
            {
                EditorGUILayout.BeginVertical(GUI.skin.box);
                {
                    EditorGUILayout.BeginHorizontal();
                    {
                        if (GUILayout.Button("Add key"))
                        {
                            RecordObject("Localization Storage Change");

                            Target.Keys.Add("Key " + Target.Keys.Count);
                            for (int i = 0; i < Target.LanguagesData.Count; i++)
                            {
                                Target.LanguagesData[i].Strings.Add("?");
                            }
                        }

                        if (GUILayout.Button("Import CSV"))
                        {
                            ImportCSV();
                        }

                        if (GUILayout.Button("Export CSV"))
                        {
                            ExportCSV();
                        }
                    }
                    EditorGUILayout.EndHorizontal();

                    _searchBar.Draw();
                }
                EditorGUILayout.EndVertical();
                EditorGUILayout.Space();

                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUILayout.LabelField("Key", GUILayout.Width(100));
                    EditorGUILayout.LabelField("String", GUILayout.Width(100));
                }
                EditorGUILayout.EndVertical();

                var textAreaStyle = GUI.skin.box;
                textAreaStyle.normal.textColor = Color.gray;
                textAreaStyle.fontStyle        = FontStyle.Normal;
                textAreaStyle.alignment        = TextAnchor.MiddleLeft;

                int searchResultsCount = 0;
                for (int i = 0; i < Target.Keys.Count; i++)
                {
                    if (!_searchBar.IsEmpty && !_searchBar.IsMatchingTheFilter(Target.Keys[i]) && !_searchBar.IsMatchingTheFilter(Target.LanguagesData[LangIndex].Strings[i]))
                    {
                        continue;
                    }

                    searchResultsCount++;
                    EditorGUILayout.BeginHorizontal(GUI.skin.box);
                    {
                        Target.Keys[i] = EditorGUILayout.TextField(Target.Keys[i], GUILayout.Width(100));
                        Target.LanguagesData[LangIndex].Strings[i] = EditorGUILayout.TextArea(Target.LanguagesData[LangIndex].Strings[i], textAreaStyle, GUILayout.ExpandWidth(true));

                        if (GUILayout.Button("X", GUILayout.Width(20)))
                        {
                            RecordObject("Localization Storage Change");

                            Target.Keys.RemoveAt(i);
                            for (int k = 0; k < Target.LanguagesData.Count; k++)
                            {
                                Target.LanguagesData[k].Strings.RemoveAt(i);
                            }
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.Space();
                }

                if (searchResultsCount == 0)
                {
                    EditorGUILayout.LabelField("No matches found...", LabelStyle);
                }
            }
            EditorGUILayout.EndVertical();
        }