docs.unity3d.com
    Show / Hide Table of Contents

    Class ElementAdderMenuCommandAttribute

    Annotate IElementAdderMenuCommand<TContext> implementations with a ElementAdderMenuCommandAttribute to associate it with the contract type of addable elements.

    Inheritance
    Object
    Attribute
    ElementAdderMenuCommandAttribute
    Namespace: Unity.VisualScripting.ReorderableList.Element_Adder_Menu
    Syntax
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
    public sealed class ElementAdderMenuCommandAttribute : Attribute, _Attribute
    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) {
         // xTODO: 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>) {
         // xTODO: Add favorite items to the shopping list!
     }
    }

    Constructors

    ElementAdderMenuCommandAttribute(Type)

    Initializes a new instance of the ElementAdderMenuCommandAttribute class.

    Declaration
    public ElementAdderMenuCommandAttribute(Type contractType)
    Parameters
    Type Name Description
    Type contractType

    Contract type of addable elements.

    Properties

    ContractType

    Gets the contract type of addable elements.

    Declaration
    public Type ContractType { get; }
    Property Value
    Type Description
    Type

    Extension Methods

    XAnalyserProvider.Analyser(Object, IGraphContext)
    XAnalyserProvider.Analyser<TAnalyser>(Object, IGraphContext)
    XAnalyserProvider.Analysis(Object, IGraphContext)
    XAnalyserProvider.Analysis<TAnalysis>(Object, IGraphContext)
    XAnalyserProvider.Analyser(Object, GraphReference)
    XAnalyserProvider.Analyser<TAnalyser>(Object, GraphReference)
    XAnalyserProvider.Analysis(Object, GraphReference)
    XAnalyserProvider.Analysis<TAnalysis>(Object, GraphReference)
    XDescriptorProvider.Describe(Object)
    XDescriptorProvider.HasDescriptor(Object)
    XDescriptorProvider.Descriptor(Object)
    XDescriptorProvider.Descriptor<TDescriptor>(Object)
    XDescriptorProvider.Description(Object)
    XDescriptorProvider.Description<TDescription>(Object)
    Cloning.Clone(Object, ICloner, Boolean)
    Cloning.Clone<T>(T, ICloner, Boolean)
    Cloning.CloneViaFakeSerialization(Object)
    Cloning.CloneViaFakeSerialization<T>(T)
    ConversionUtility.IsConvertibleTo(Object, Type, Boolean)
    ConversionUtility.IsConvertibleTo<T>(Object, Boolean)
    ConversionUtility.ConvertTo(Object, Type)
    ConversionUtility.ConvertTo<T>(Object)
    TypeUtility.ToShortString(Object, Int32)
    Serialization.CloneViaSerialization<T>(T, Boolean)
    Serialization.CloneViaSerializationInto<TSource, TDestination>(TSource, ref TDestination, Boolean)
    Serialization.Serialize(Object, Boolean)
    LinqUtility.Yield<T>(T)
    UnityObjectUtility.IsUnityNull(Object)
    UnityObjectUtility.ToSafeString(Object)
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023