示例#1
0
        public static Pair <ITypeElement, ITypeMember>?PropertyFromColorElement(ITypeElement qualifierType, IColorElement colorElement, IPsiModule module)
        {
            var colorName = UnityNamedColors.GetColorName(colorElement.RGBColor);

            if (string.IsNullOrEmpty(colorName))
            {
                return(null);
            }

            var unityColorType = GetInstance(module).UnityColorType;

            if (unityColorType == null || !unityColorType.Equals(qualifierType))
            {
                return(null);
            }

            var colorProperties    = GetStaticColorProperties(unityColorType);
            var propertyTypeMember = colorProperties.FirstOrDefault(p => p.ShortName == colorName);

            if (propertyTypeMember == null)
            {
                return(null);
            }

            return(Pair.Of(unityColorType, propertyTypeMember));
        }
示例#2
0
        public IconId GetImageId(IDeclaredElement declaredElement, PsiLanguageType languageType, out bool canApplyExtensions)
        {
            canApplyExtensions = false;

            var typeMember = declaredElement as ITypeMember;

            if (typeMember == null)
            {
                return(null);
            }

            if (!UnityColorTypes.IsColorProperty(typeMember))
            {
                return(null);
            }

            var color = UnityNamedColors.Get(typeMember.ShortName);

            if (color == null)
            {
                return(null);
            }

            return(new ColorIconId(color.Value));
        }
示例#3
0
        public static bool IsColorProperty(ITypeMember typeMember)
        {
            if (typeMember is IProperty && typeMember.IsStatic)
            {
                var unityColorTypes = GetInstance(typeMember.Module);
                return(unityColorTypes.IsUnityColorTypeSupportingProperties(typeMember.GetContainingType()) &&
                       UnityNamedColors.Get(typeMember.ShortName).HasValue);
            }

            return(false);
        }
 public IEnumerable <IColorElement> GetColorTable()
 {
     return(UnityNamedColors.GetColorTable());
 }