Added Stepper and Segmented Controls to the README.md

Refactored Segmented Control and Stepper to support the more generic "Selectable" interface.
release
Simon Jackson 2017-07-26 22:32:48 +01:00
parent 8e443b98c7
commit 603d85126f
3 changed files with 25 additions and 24 deletions

View File

@ -106,43 +106,44 @@ There are almost 70+ extension controls / effect and other utilities in the proj
##[UI Extensions controls list](https://bitbucket.org/UnityUIExtensions/unity-ui-extensions/wiki/Controls)##
[Controls](https://bitbucket.org/UnityUIExtensions/unity-ui-extensions/wiki/Controls#Controls)|||||
[Controls](https://bitbucket.org/UnityUIExtensions/unity-ui-extensions/wiki/Controls#markdown-header-controls)|||||
------|------|------|------|
Accordion|ColorPicker|SelectionBox|UIButton|UIFlippable
ComboBox|AutoCompleteComboBox|DropDownList|BoundToolTip|UIWindowBase
UI_Knob|TextPic|InputFocus|Box Slider|CooldownButton
Segmented Control|Stepper|||
||||
[Primitives](https://bitbucket.org/UnityUIExtensions/unity-ui-extensions/wiki/Controls#Primitives)|||||
[Primitives](https://bitbucket.org/UnityUIExtensions/unity-ui-extensions/wiki/Controls#markdown-header-primitives)|||||
------|------|------|------|
UILineRenderer|UILineTextureRenderer|UICircle|DiamondGraph|UICornerCut
UIPolygon||||
||||
[Layouts](https://bitbucket.org/UnityUIExtensions/unity-ui-extensions/wiki/Controls#Layouts)|||||
[Layouts](https://bitbucket.org/UnityUIExtensions/unity-ui-extensions/wiki/Controls#markdown-header-layouts)|||||
------|------|------|------|
Horizontal Scroll Snap|Vertical Scroll Snap|Flow Layout Group|Radial Layout|Tile Size Fitter
Scroll Snap (alt implementation)|Reorderable List|UI Vertical Scroller|Curved Layout|Table Layout
||||
[Effects](https://bitbucket.org/UnityUIExtensions/unity-ui-extensions/wiki/Controls#Effects)|||||
[Effects](https://bitbucket.org/UnityUIExtensions/unity-ui-extensions/wiki/Controls#markdown-header-effect_components)|||||
------|------|------|------|
Best Fit Outline|Curved Text|Gradient|Gradient2|Letter Spacing
NicerOutline|RaycastMask|UIFlippable|UIImageCrop|SoftAlphaMask
CylinderText|UIParticleSystem|||
||||
[VR Components](https://bitbucket.org/UnityUIExtensions/unity-ui-extensions/wiki/Controls#VR)|||||
[VR Components](https://bitbucket.org/UnityUIExtensions/unity-ui-extensions/wiki/Controls#markdown-header-vr_components)|||||
------|------|------|------|
VRCursor|VRInputModule|||
||||
[Input Modules](https://bitbucket.org/UnityUIExtensions/unity-ui-extensions/wiki/Controls#InputModules)|||||
[Input Modules](https://bitbucket.org/UnityUIExtensions/unity-ui-extensions/wiki/Controls#markdown-header-input_modules)|||||
------|------|------|------|
AimerInputModule|GamePadInputModule|||
||||
[Additional Components](https://bitbucket.org/UnityUIExtensions/unity-ui-extensions/wiki/Controls#Additional_Components)|||||
[Additional Components](https://bitbucket.org/UnityUIExtensions/unity-ui-extensions/wiki/Controls#markdown-header-additional_components)|||||
------|------|------|------|
ReturnKeyTrigger|TabNavigation|uGUITools|ScrollRectTweener|ScrollRectLinker
ScrollRectEx|UI_InfiniteScroll|UI_ScrollRectOcclusion|UIScrollToSelection|UISelectableExtension

View File

@ -12,7 +12,7 @@ namespace UnityEngine.UI.Extensions
[RequireComponent(typeof(RectTransform))]
public class SegmentedControl : UIBehaviour
{
private Button[] m_segments;
private Selectable[] m_segments;
[SerializeField]
[Tooltip("A GameObject with an Image to use as a separator between segments. Size of the RectTransform will determine the size of the separator used.\nNote, make sure to disable the separator GO so that it does not affect the scene")]
private Graphic m_separator;
@ -28,7 +28,7 @@ namespace UnityEngine.UI.Extensions
[Tooltip("Event to fire once the selection has been changed")]
private SegmentSelectedEvent m_onValueChanged = new SegmentSelectedEvent();
protected internal Button selectedSegment;
protected internal Selectable selectedSegment;
protected float SeparatorWidth
{
@ -48,7 +48,7 @@ namespace UnityEngine.UI.Extensions
[Serializable]
public class SegmentSelectedEvent : UnityEvent<int> { }
public Button[] segments
public Selectable[] segments
{
get
{
@ -135,9 +135,9 @@ namespace UnityEngine.UI.Extensions
}
#endif
private Button[] GetChildSegments()
private Selectable[] GetChildSegments()
{
var buttons = GetComponentsInChildren<Button>();
var buttons = GetComponentsInChildren<Selectable>();
if (buttons.Length < 2)
{
throw new InvalidOperationException("A segmented control must have at least two Button children");
@ -224,7 +224,7 @@ namespace UnityEngine.UI.Extensions
}
}
[RequireComponent(typeof(Button))]
[RequireComponent(typeof(Selectable))]
public class Segment :
UIBehaviour,
IPointerClickHandler,
@ -255,9 +255,9 @@ namespace UnityEngine.UI.Extensions
get { return GetComponentInParent<SegmentedControl>(); }
}
internal Button button
internal Selectable button
{
get { return GetComponent<Button>(); }
get { return GetComponent<Selectable>(); }
}
[SerializeField]

View File

@ -12,7 +12,7 @@ namespace UnityEngine.UI.Extensions
[RequireComponent(typeof(RectTransform))]
public class Stepper : UIBehaviour
{
private Button[] _sides;
private Selectable[] _sides;
[SerializeField]
[Tooltip("The current step value of the control")]
private int _value = 0;
@ -55,7 +55,7 @@ namespace UnityEngine.UI.Extensions
[Serializable]
public class StepperValueChangedEvent : UnityEvent<int> { }
public Button[] sides
public Selectable[] sides
{
get
{
@ -103,9 +103,9 @@ namespace UnityEngine.UI.Extensions
}
#endif
private Button[] GetSides()
private Selectable[] GetSides()
{
var buttons = GetComponentsInChildren<Button>();
var buttons = GetComponentsInChildren<Selectable>();
if (buttons.Length != 2)
{
throw new InvalidOperationException("A stepper must have two Button children");
@ -159,13 +159,13 @@ namespace UnityEngine.UI.Extensions
_onValueChanged.Invoke(value);
}
private void DisableAtExtremes(Button[] sides)
private void DisableAtExtremes(Selectable[] sides)
{
sides[0].interactable = wrap || value > minimum;
sides[1].interactable = wrap || value < maximum;
}
private void RecreateSprites(Button[] sides)
private void RecreateSprites(Selectable[] sides)
{
for (int i = 0; i < 2; i++)
{
@ -194,7 +194,7 @@ namespace UnityEngine.UI.Extensions
}
}
public void LayoutSides(Button[] sides = null)
public void LayoutSides(Selectable[] sides = null)
{
sides = sides ?? this.sides;
@ -231,10 +231,10 @@ namespace UnityEngine.UI.Extensions
}
}
[RequireComponent(typeof(Button))]
[RequireComponent(typeof(Selectable))]
public class StepperSide : UIBehaviour, IPointerClickHandler, ISubmitHandler
{
Button button { get { return GetComponent<Button>(); } }
Selectable button { get { return GetComponent<Selectable>(); } }
Stepper stepper { get { return GetComponentInParent<Stepper>(); } }