コード例 #1
0
        public void TagGUI()
        {
            var selectedPresets = serializedObject.targetObjects.Cast <ScreenshotResolutionAsset>().ToList();

            // Create tag
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Create tag", GUILayout.MaxWidth(100));
            newTag = EditorGUILayout.TextField(newTag);
            if (GUILayout.Button("Add", GUILayout.MaxWidth(40)))
            {
                foreach (var selected in selectedPresets)
                {
                    TagDatabaseAsset.AddTag((ScreenshotResolutionAsset)selected, newTag);
                }
            }
            EditorGUILayout.EndHorizontal();


            EditorGUILayout.Separator();

            // Existing tags
            var tags = TagDatabaseAsset.GetAllTags();

            foreach (var tag in tags)
            {
                bool hasTag = TagDatabaseAsset.HasTag(selectedPresets, tag);

                EditorGUILayout.BeginHorizontal();
                if (!hasTag)
                {
                    if (GUILayout.Button("+", GUILayout.MaxWidth(20)))
                    {
                        foreach (var preset in selectedPresets)
                        {
                            TagDatabaseAsset.AddTag(preset, tag);
                        }
                    }
                    EditorGUILayout.LabelField(tag, EditorStyles.miniLabel);
                }
                else
                {
                    if (GUILayout.Button("-", GUILayout.MaxWidth(20)))
                    {
                        foreach (var preset in selectedPresets)
                        {
                            TagDatabaseAsset.RemoveTag(preset, tag);
                        }
                    }
                    EditorGUILayout.LabelField(tag, EditorStyles.boldLabel);
                }
                EditorGUILayout.EndHorizontal();
            }
        }
コード例 #2
0
        void DrawTagsPopup()
        {
            tags.Clear();
            tags = TagDatabaseAsset.GetAllTags();
            tags.Insert(0, "All");
            int selectedTag = EditorGUILayout.Popup("Tags", tagsId, tags.ToArray());

            if (tagsId != selectedTag)
            {
                tagsId = selectedTag;
                if (tagsId != 0)
                {
                    m_TagFilter = tags[tagsId];
                }
                else
                {
                    m_TagFilter = "";
                }
                UpdateDeviceSelectorList();
            }
        }