Skip to content

Commit 417a70b

Browse files
committed
Update documentation comments
1 parent a69629b commit 417a70b

File tree

2 files changed

+38
-12
lines changed

2 files changed

+38
-12
lines changed

Runtime/NavigationStack.cs

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
namespace Zigurous.UI
77
{
88
/// <summary>
9-
/// Keeps track of a stack of selected game objects as to allow for easy
10-
/// back navigation.
9+
/// Manages a stack of game objects for menu navigation purposes. This is
10+
/// especially useful to handle backwards navigation by simply popping off
11+
/// the last item in the stack.
1112
/// </summary>
1213
[RequireComponent(typeof(EventSystem))]
1314
[AddComponentMenu("Zigurous/UI/Navigation/Navigation Stack")]
@@ -29,10 +30,10 @@ public class NavigationStack : MonoBehaviour
2930
public GameObject Top => this.items.Count > 0 ? this.items.Peek() : null;
3031

3132
/// <summary>
32-
/// The input action to handle navigating backwards in the stack by
33-
/// popping items off.
33+
/// The input action that handles backwards navigation by popping items
34+
/// off the stack.
3435
/// </summary>
35-
[Tooltip("The input action to handle navigating backwards in the stack by popping items off.")]
36+
[Tooltip("The input action that handles backwards navigation by popping items off the stack.")]
3637
public InputAction backNavigationInput = new InputAction("MenuBackNavigation", InputActionType.Button);
3738

3839
/// <summary>
@@ -92,6 +93,11 @@ private void OnDisable()
9293
this.backNavigationInput.Disable();
9394
}
9495

96+
/// <summary>
97+
/// Pushes a game object onto the stack, effectively navigating
98+
/// forwards.
99+
/// </summary>
100+
/// <param name="selected">The game object to push onto the stack.</param>
95101
public void Push(GameObject selected)
96102
{
97103
if (selected != null || this.allowNullSelections)
@@ -105,16 +111,23 @@ public void Push(GameObject selected)
105111
}
106112
}
107113

108-
public void Back()
114+
/// <summary>
115+
/// Pops the last game object off the stack, effectively navigating
116+
/// backwards.
117+
/// </summary>
118+
/// <returns>The game object that was popped off the stack.</returns>
119+
public GameObject Pop()
109120
{
110121
if (this.items.Count == 0) {
111-
return;
122+
return null;
112123
}
113124

125+
GameObject top = null;
126+
114127
// Pop off the top of the stack
115128
if (this.items.Count > 1 || this.allowEmptyStack)
116129
{
117-
GameObject top = this.items.Pop();
130+
top = this.items.Pop();
118131

119132
if (this.setActiveState && top != null) {
120133
top.SetActive(false);
@@ -134,12 +147,14 @@ public void Back()
134147

135148
this.eventSystem.SetSelectedGameObject(previous);
136149
}
150+
151+
return top;
137152
}
138153

139154
private void OnBack(InputAction.CallbackContext context)
140155
{
141156
if (context.performed) {
142-
Back();
157+
Pop();
143158
}
144159
}
145160

Runtime/ScrollToSelection.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,23 @@ namespace Zigurous.UI
1414
public class ScrollToSelection : MonoBehaviour
1515
{
1616
/// <summary>
17-
/// A scroll direction type.
17+
/// A scroll direction.
1818
/// </summary>
1919
public enum ScrollDirection
2020
{
21+
/// <summary>
22+
/// Scrolls in the y-axis.
23+
/// </summary>
2124
Vertical,
25+
26+
/// <summary>
27+
/// Scrolls in the x-axis.
28+
/// </summary>
2229
Horizontal,
30+
31+
/// <summary>
32+
/// Scrolls in both the x-axis and the y-axis.
33+
/// </summary>
2334
Both,
2435
}
2536

@@ -36,8 +47,8 @@ public enum ScrollDirection
3647
public float scrollSpeed = 10.0f;
3748

3849
/// <summary>
39-
/// Whether the ScrollRect is currently being manually scrolled. This
40-
/// allows the user to scroll freely with the mouse even when a child
50+
/// Whether the ScrollRect is currently being scrolled manually. This
51+
/// allows the user to freely scroll with the mouse even when a child
4152
/// element is selected.
4253
/// </summary>
4354
public bool manualScrolling { get; private set; }

0 commit comments

Comments
 (0)