예제 #1
0
        private static TextAnchor ToTextAnchor(IconAnchor anchor)
        {
            switch (anchor)
            {
            default:
            case IconAnchor.Center:
                return(TextAnchor.MiddleCenter);

            case IconAnchor.Top:
                return(TextAnchor.UpperCenter);

            case IconAnchor.Bottom:
                return(TextAnchor.LowerCenter);

            case IconAnchor.Left:
                return(TextAnchor.MiddleLeft);

            case IconAnchor.Right:
                return(TextAnchor.MiddleRight);

            case IconAnchor.TopLeft:
                return(TextAnchor.UpperLeft);

            case IconAnchor.TopRight:
                return(TextAnchor.UpperRight);

            case IconAnchor.BottomLeft:
                return(TextAnchor.LowerLeft);

            case IconAnchor.BottomRight:
                return(TextAnchor.LowerRight);
            }
        }
예제 #2
0
        private static Vector2 AnchorToVector(IconAnchor anchor)
        {
            switch (anchor)
            {
            default:
            case IconAnchor.Center:
                return(new Vector2(0.5f, 0.5f));

            case IconAnchor.Top:
                return(new Vector2(0.5f, 1.0f));

            case IconAnchor.Bottom:
                return(new Vector2(0.5f, 0.0f));

            case IconAnchor.Left:
                return(new Vector2(0.0f, 0.5f));

            case IconAnchor.Right:
                return(new Vector2(1.0f, 0.5f));

            case IconAnchor.TopLeft:
                return(new Vector2(0.0f, 1.0f));

            case IconAnchor.TopRight:
                return(new Vector2(1.0f, 1.0f));

            case IconAnchor.BottomLeft:
                return(new Vector2(0.0f, 0.0f));

            case IconAnchor.BottomRight:
                return(new Vector2(1.0f, 0.0f));
            }
        }
예제 #3
0
        /// <summary>
        /// <para>Marks a field to be used as a graphic for a custom icon.</para>
        /// </summary>
        /// <param name="width">An expression that's evaluated to determine the width of the icon.</param>
        /// <param name="height">An expression that's evaluated to determine the height of the icon.</param>
        /// <param name="x">An expression that's evaluated to determine a horizontal offset of the icon.</param>
        /// <param name="y">An expression that's evaluated to determine a vertical offset of the icon.</param>
        /// <param name="maxSize">A value used to determine the max size of the icon.</param>
        /// <param name="anchor">An anchor that all difference in scale is orientated around.</param>
        /// <param name="aspect">A value used to determine the aspect of the icon.</param>
        /// <param name="display">An expression that's evaluated to whether the icon should be displayed.</param>
        /// <param name="tint">A tint to apply to the icon.</param>
        /// <param name="layer">A value used to determine the layer of the icon.</param>
        /// <param name="fontStyle">A font style to use on all rendered text.</param>
        /// <param name="textAnchor">An anchor for all rendered text.</param>
        /// <param name="projection">A camera projection for all rendered Prefabs.</param>
        /// <param name="lineNumber">The line number that this attribute is implemented. Indended for compiler usage.</param>
        /// <param name="filePath">The local file path that this attribute is implemented. Indended for compiler usage.</param>
        public AssetIconAttribute(
            string width              = "100%",
            string height             = "100%",
            string x                  = "0",
            string y                  = "0",
            int maxSize               = 64,
            IconAnchor anchor         = IconAnchor.Center,
            IconAspect aspect         = IconAspect.Fit,
            string display            = "true",
            string tint               = IconColor.White,
            int layer                 = 0,
            FontStyle fontStyle       = FontStyle.Normal,
            IconAnchor textAnchor     = IconAnchor.Center,
            IconProjection projection = IconProjection.Perspective,
#if UNITY_EDITOR && (!NET_2_0 && !NET_2_0_SUBSET && UNITY_2017_1_OR_NEWER)
            [CallerLineNumber]
#endif
            int lineNumber = -1,
#if UNITY_EDITOR && (!NET_2_0 && !NET_2_0_SUBSET && UNITY_2017_1_OR_NEWER)
            [CallerFilePath]
#endif
            string filePath = null
            )
        {
            style = new AssetIconsStyle()
            {
                Width      = width,
                Height     = height,
                X          = x,
                Y          = y,
                MaxSize    = maxSize,
                Anchor     = anchor,
                Aspect     = aspect,
                Tint       = tint,
                Layer      = layer,
                FontStyle  = fontStyle,
                Projection = projection,
                Display    = display,
                TextAnchor = textAnchor,
            };

            this.lineNumber = lineNumber;
            this.filePath   = filePath;
        }