コード例 #1
0
 /// <summary>
 /// Creates an attribute of the given type.
 /// </summary>
 /// <param name="width">Width of the icon. Append percentage symbol for relative to max width.</param>
 /// <param name="height">Height of the icon. Append percentage symbol for relative to max height.</param>
 /// <param name="x">Horizontal position of icon from top-left corner. Append percentage for relative to width.</param>
 /// <param name="y">Vertical position of icon from top-left corner. Append percentage for relative to height.</param>
 /// <param name="tint">The color to tint the final icon graphic with.</param>
 /// <param name="maxSize"></param>
 /// <param name="iconAnchor"></param>
 /// <param name="textAnchor"></param>
 /// <param name="display"></param>
 /// <param name="layer"></param>
 /// <param name="fontStyle"></param>
 /// <param name="dontEraseDefault"></param>
 /// <param name="grid"></param>
 /// <param name="customValues">Array of custom values to be passed to your custom drawers..</param>
 public PvIconAttribute(string width          = "100%", string height = "100%", string x = "0", string y = "0",
                        PvScaleMode scaleMode = PvScaleMode.ScaleToFit,
                        string tint           = "#FFFFFFFF", int maxSize = 128,
                        PvAnchor iconAnchor   = PvAnchor.MiddleCenter, PvAnchor textAnchor = PvAnchor.MiddleCenter,
                        string display        = "", int layer      = 0, PvFontStyle fontStyle = PvFontStyle.Normal, string material = "",
                        bool dontEraseDefault = false, string grid = "",
                        object[] customValues = null)
 {
     Width     = width;
     Height    = height;
     X         = x;
     Y         = y;
     ScaleMode = scaleMode;
     if (!ColorUtility.TryParseHtmlString(tint, out Tint))
     {
         Tint = Color.white;
     }
     MaxSize          = maxSize;
     IconAnchor       = iconAnchor;
     Display          = display;
     Layer            = layer;
     FontStyle        = fontStyle;
     Material         = material;
     DontEraseDefault = dontEraseDefault;
     TextAnchor       = textAnchor;
     Grid             = grid;
     CustomData       = customValues ?? Array.Empty <object>();
 }
コード例 #2
0
        /// <summary>
        /// Gets the normalized position for each anchor w.r.t. top-left being (0, 0) and bottom-right being (1,1).
        /// </summary>
        public static Vector2 GetNormalizedOffsetFromAnchor(PvAnchor attrIconAnchor)
        {
            switch (attrIconAnchor)
            {
            case PvAnchor.UpperLeft: return(new Vector2(0, 0));

            case PvAnchor.UpperCenter: return(new Vector2(0.5f, 0));

            case PvAnchor.UpperRight: return(new Vector2(1, 0));

            case PvAnchor.MiddleLeft: return(new Vector2(0, 0.5f));

            case PvAnchor.MiddleCenter: return(new Vector2(0.5f, 0.5f));

            case PvAnchor.MiddleRight: return(new Vector2(1, 0.5f));

            case PvAnchor.LowerLeft: return(new Vector2(0, 1));

            case PvAnchor.LowerCenter: return(new Vector2(0.5f, 1));

            case PvAnchor.LowerRight: return(new Vector2(1f, 1));

            default: throw new ArgumentOutOfRangeException(nameof(attrIconAnchor), attrIconAnchor, null);
            }
        }
コード例 #3
0
 public static TextAnchor UnityTextAnchor(this PvAnchor anchor)
 {
     return((TextAnchor)anchor);
 }