Display_UI
Derived from
DisplayObj
Display where dots are based on images that change colors when turning on and off. This display is meant to be used is UI element. It's position follows pivot point of RectTransform. Display (dots) size can be also set to fit inside the RectTransform so the actual size of display will change depending on UI layout settings.
Enums
public enum UIFits | List of different types how to fit this display in UI RectTransform. | public enum UIPositions | List of positions inside RectTransform if display doesn't fill whole RectTransform area. |
Properties
public int ColorCount | Gets or sets the count of colors this display's dots can have. | public Vector2 DotSize | Size of single dot. | public Color OffColor | Color of single dot sprite when it is turned to off-state (color 0). | public Color OnColor | Color of single dot sprite when it is turned to on-state (color 1). | public UIFits UIFit | Set or get UI fit type, one of the values from enum UIFits. | public UIPositions UIPosition | Set or get position of the display inside RectTransform, one of the values from enum UIPositions. |
Methods
Enums
public enum UIFits List of different types how to fit this display in UI RectTransform. Items | KeepDotSize | Use dot size defined in Display. | | FitToRectTransform | Shrink or enlarge all the dots so that they fill RectTransform of this component. | | FitButKeepAspectRatio | Shrink or enlarge all the dots so that they fill RectTransform of this component but keep original aspect ratio of dots. |
public enum UIPositions List of positions inside RectTransform if display doesn't fill whole RectTransform area. Items | FollowPivotPoint | Position follows pivot point. | | UpperLeft | Set display to upper left corner of RectTransform. | | UpperCenter | Set display to upper center position of RectTransform. | | UpperRight | Set display to upper right corner of RectTransform. | | MiddleLeft | Set display to middle left position of RectTransform. | | MiddleCenter | Set display to middle center position of RectTransform. | | MiddleRight | Set display to middle right position of RectTransform. | | LowerLeft | Set display to lower left corner of RectTransform. | | LowerCenter | Set display to lower center position of RectTransform. | | LowerRight | Set display to lower right corner of RectTransform. |
Properties
public int ColorCount Gets or sets the count of colors this display's dots can have. Default and minimum is two colors. Value | Amount of different possible color states. |
public Vector2 DotSize Size of single dot. Value | Size of single dot as Vector2 |
public Color OffColor Color of single dot sprite when it is turned to off-state (color 0). This have same effect than using SetColor(0,Color) or GetColor(0,Color) methods and is here for backward compatibility. Value | Dot color when in off-state. |
public Color OnColor Color of single dot sprite when it is turned to on-state (color 1). This have same effect than using SetColor(1,Color) or GetColor(1,Color) methods and is here for backward compatibility. Value | Dot color when in on-state. |
public UIFits UIFit Set or get UI fit type, one of the values from enum UIFits. When using type that tries to fit the display inside RectTransform, make sure this GameObject RectTransform width and height are not set to zero. Value | One of the choices from enum UIFits |
public UIPositions UIPosition Set or get position of the display inside RectTransform, one of the values from enum UIPositions. This setting have no effect if UIFit is set FitToRectTransform because then display is filling whole RectTransform area. Value | One of the choices from enum UIPositions |
Methods
public Color GetColor (int state) Gets color used in dot sprites when dot state is set to 'index'. Parameters | state | 0 is dot 'off' state, 1 is default 'on' state, 2 and above are additional 'on' state colors. |
public void SetColor (int state, Color color) Sets color used in dot sprites when dot state is set to 'index'. Parameters | state | 0 is dot 'off' state, 1 is default 'on' state, 2 and above are additional 'on' state colors. | | color | Color to use. |
public void checkAndSetParent () Check whatever this object is child of UI Canvas and tries to set the parent if not. If there is no canvas in hierarchy, this method will create one. If this object parent is changed, object's scale and anchored position will reset also.
Note that this method is normally used only internally in Unity Editor and there is no need to call this when application is running. If you create new UI-type DotMatrix from prefab runtime, rather make sure your scene already contains Canvas and then use normal myUIDotMatrix.transform.SetParent(myKnownCanvasOrOtherUIElement.transform) method to set parent as with any UI object.
|