Beispiel #1
0
    public static TagsEditorWindow CallWindow()
    {
        TagsEditorWindow _window = GetWindow <TagsEditorWindow>("Tags Editor");

        _window.Show();
        return(_window);
    }
Beispiel #2
0
    /// <summary>
    /// Draws an editor for the custom tag system for the GameObject class.
    /// </summary>
    private void DrawTagSystem()
    {
        // If editing game object(s) tag has changed, update its tags
        if (targetGO.Select(g => g.tag) != lastTags)
        {
            GetObjectsTags();
            Repaint();
        }

        EditorGUILayout.BeginHorizontal();

        // Title of the tag section
        EditorGUILayout.LabelField(new GUIContent("Tags"), EditorStyles.boldLabel);

        // Creates a button at the top right of the inspector to open the tags editor window
        // First, get its rect, then draw it
        Rect _editButtonRect = GUILayoutUtility.GetRect(new GUIContent("Edit Tags"), EditorStyles.miniButtonRight, GUILayout.Width(100));

        if (GUI.Button(_editButtonRect, "Edit Tags", EditorStyles.miniButtonRight))
        {
            TagsEditorWindow.CallWindow();
        }

        EditorGUILayout.EndHorizontal();

        // Draws the tag section for editing objects
        if (isUnfolded)
        {
            // Draws a tags field, to edit tag from editing object(s)
            Action <Tag> _addTagCallback    = new Action <Tag>((Tag _tag) => MultiTagsUtility.AddTagToGameObjects(_tag, targetGO));
            Action <Tag> _removeTagCallback = new Action <Tag>((Tag _tag) => MultiTagsUtility.RemoveTagFromGameObjects(_tag, targetGO));

            MultiTagsUtility.GUILayoutTagsField(editingTags, _addTagCallback, _removeTagCallback, true);

            if (haveTargetsDifferentTags)
            {
                EditorGUILayout.HelpBox("You are editing Game Objects with different tags.\n" +
                                        "Only tags in common will be displayed in the inspector.", MessageType.Info);
            }
        }

        // Males a space in the editor to finish
        GUILayout.Space(7);
    }