public bool IsAvailable(IUserDataHolder cache)
        {
            var identifier = myDataProvider.GetSelectedElement <ICSharpIdentifier>();

            var classLikeDeclaration = ClassLikeDeclarationNavigator.GetByNameIdentifier(identifier);

            if (classLikeDeclaration == null)
            {
                return(false);
            }

            ITypeElement declaredElement = classLikeDeclaration.DeclaredElement;

            if (declaredElement.DerivesFrom(KnownTypes.EditorWindow))
            {
                return(false);
            }

            if (declaredElement.DerivesFrom(KnownTypes.Editor))
            {
                return(false);
            }

            var existingAttribute = classLikeDeclaration.GetAttribute(KnownTypes.CreateAssetMenuAttribute);

            return(existingAttribute == null && declaredElement.DerivesFromScriptableObject());
        }
        public bool IsAvailable(IUserDataHolder cache)
        {
            var identifier = myDataProvider.GetSelectedElement <ICSharpIdentifier>();

            var classLikeDeclaration = ClassLikeDeclarationNavigator.GetByNameIdentifier(identifier);

            if (classLikeDeclaration == null)
            {
                return(false);
            }

            var existingAttribute = classLikeDeclaration.GetAttribute(KnownTypes.CreateAssetMenu);

            return(existingAttribute == null && UnityApi.IsDescendantOfScriptableObject(classLikeDeclaration.DeclaredElement));
        }
示例#3
0
 public override bool IsAvailable(IUserDataHolder cache)
 {
     this.Declaration = ClassLikeDeclarationNavigator.GetByNameIdentifier(this._provider.GetSelectedElement <ICSharpIdentifier>());
     return(this.Declaration != null);
 }