ElementAdderMenuCommandAttribute Class

Rotorz ReorderableList

ElementAdderMenuCommandAttribute Class
Annotate IElementAdderMenuCommandTContext implementations with a ElementAdderMenuCommandAttribute to associate it with the contract type of addable elements.
Inheritance Hierarchy
SystemObject  SystemAttribute
    Rotorz.ReorderableListElementAdderMenuCommandAttribute

Namespace: Rotorz.ReorderableList
Assembly: Editor.ReorderableList (in Editor.ReorderableList.dll) Version: 0.0.0.0 (0.3.0.0)
Syntax
public sealed class ElementAdderMenuCommandAttribute : Attribute
public sealed class ElementAdderMenuCommandAttribute extends Attribute

The ElementAdderMenuCommandAttribute type exposes the following members.

Constructors
  NameDescription
Public methodElementAdderMenuCommandAttribute
Initializes a new instance of the ElementAdderMenuCommandAttribute class.
Top
Methods
  NameDescription
Public methodEquals
Returns a value that indicates whether this instance is equal to a specified object.
(Inherited from Attribute.)
Public methodGetHashCode
Returns the hash code for this instance.
(Inherited from Attribute.)
Public methodIsDefaultAttribute
When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.
(Inherited from Attribute.)
Public methodMatch
When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.
(Inherited from Attribute.)
Top
Properties
  NameDescription
Public propertyContractType
Gets the contract type of addable elements.
Public propertyTypeId
When implemented in a derived class, gets a unique identifier for this Attribute.
(Inherited from Attribute.)
Top
Examples

The following source code demonstrates how to add a helper menu command to the add element menu of a shopping list:

[ElementAdderMenuCommand(typeof(ShoppingItem))]
public class AddFavoriteShoppingItemsCommand : IElementAdderMenuCommand<ShoppingList> {
    public AddFavoriteShoppingItemsCommand() {
        Content = new GUIContent("Add Favorite Items");
    }

    public GUIContent Content { get; private set; }

    public bool CanExecute(IElementAdder<ShoppingList> elementAdder) {
        return true;
    }
    public void Execute(IElementAdder<ShoppingList> elementAdder) {
        // TODO: Add favorite items to the shopping list!
    }
}
@ElementAdderMenuCommand(ShoppingItem)
class AddFavoriteShoppingItemsCommand extends IElementAdderMenuCommand.<ShoppingList> {
    var _content:GUIContent = new GUIContent('Add Favorite Items');

    function get Content():GUIContent { return _content; }

    function CanExecute(elementAdder:IElementAdder.<ShoppingList>):boolean {
        return true;
    }
    function Execute(elementAdder:IElementAdder.<ShoppingList>) {
        // TODO: Add favorite items to the shopping list!
    }
}
See Also