Exemplo n.º 1
0
        private void DrawTextSelectGUI(TextData textData, ContentType contentType)
        {
            var categoryChanged = false;

            using (new EditorGUILayout.HorizontalScope())
            {
                var categories = textData.Categories.Where(x => x.ContentType == contentType).ToArray();

                // Noneが入るので1ずれる.
                var categoryIndex = categories.IndexOf(x => x.Guid == SelectionCategoryGuid) + 1;

                var categoryLabels = categories.Select(x => x.DisplayName).ToArray();

                var labels = new List <string> {
                    "None"
                };

                labels.AddRange(categoryLabels);

                EditorGUI.BeginChangeCheck();

                categoryIndex = EditorGUILayout.Popup("TextData", categoryIndex, labels.ToArray());

                if (EditorGUI.EndChangeCheck())
                {
                    UnityEditorUtility.RegisterUndo("TextDataSetterInspector-Undo", instance);

                    var newCategory = 1 <= categoryIndex ? categories[categoryIndex - 1] : null;

                    var newCategoryGuid = newCategory != null ? newCategory.Guid : string.Empty;

                    if (currentCategoryGuid != newCategoryGuid)
                    {
                        SetTextGuid(null);

                        UpdateCurrentInfo(textData);

                        currentCategoryGuid = newCategoryGuid;

                        categoryChanged = true;
                    }
                }

                using (new DisableScope(categoryIndex == 0 || TextData.Instance.Texts == null))
                {
                    GUILayout.Space(2f);

                    if (GUILayout.Button("select", EditorStyles.miniButton, GUILayout.Width(75f)))
                    {
                        TextDataSelector.Open();
                    }
                }
            }

            if (categoryChanged && string.IsNullOrEmpty(currentCategoryGuid))
            {
                SetDevelopmentText(string.Empty);
            }
        }
Exemplo n.º 2
0
        //----- property -----

        //----- method -----

        public static void Open()
        {
            if (instance != null)
            {
                instance.Close();
                instance = null;
            }

            instance = DisplayWizard <TextDataSelector>(WindowTitle);

            instance.Initialize();
        }