Skip to content

Commit 6dc15e8

Browse files
committed
Add decals and other fluff to credits
1 parent 097bc82 commit 6dc15e8

23 files changed

+2475
-1745
lines changed

Assets/Prefabs/UI/Menus/CreditsMenu.prefab

+1,381-27
Large diffs are not rendered by default.

Assets/Prefabs/UI/Menus/MenuCanvas.prefab

+59-1,703
Large diffs are not rendered by default.

Assets/Scripts/UI/MainMenu/CreditsMenu.cs

+19-15
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,44 @@
11
using System.Collections;
22
using UnityEngine;
33
using UnityEngine.InputSystem;
4-
using UnityEngine.UI;
54

65
public class CreditsMenu : MonoBehaviour
76
{
87
[SerializeField] private MainMenuController mainMenuController;
98

10-
[SerializeField] private VerticalLayoutGroup content;
9+
[SerializeField] private RectTransform content;
1110

12-
[SerializeField] private float speed = 10;
11+
[SerializeField] private RectTransform textContent;
1312

1413
[SerializeField] private RectTransform lastElement;
1514

16-
private float height = 5000;
15+
[SerializeField] private float speed = 10;
16+
1717
private int tween;
18-
private int initialTopPadding;
18+
private float height;
19+
private float initialInset;
1920

2021
private InputManager inputManager;
2122

2223
private void OnEnable()
2324
{
25+
if (inputManager)
26+
{
27+
inputManager.onCancel += Back;
28+
inputManager.onSelect += Back;
29+
inputManager.onClick += Back;
30+
}
31+
2432
StartCoroutine(StartAnimation());
2533
}
2634

2735
private IEnumerator StartAnimation()
2836
{
2937
// Wait until position of last element can be determined.
3038
yield return new WaitForEndOfFrame();
31-
initialTopPadding = content.padding.top;
32-
height = Mathf.Abs(lastElement.anchoredPosition.y + lastElement.sizeDelta.y * .5f);
39+
initialInset = content.anchorMin.y;
40+
var diffBetweenContentAndText = Mathf.Abs(content.anchoredPosition.y - textContent.anchoredPosition.y);
41+
height = diffBetweenContentAndText + Mathf.Abs(lastElement.anchoredPosition.y + lastElement.sizeDelta.y * .5f);
3342

3443
tween = LeanTween.sequence()
3544
.append(1)
@@ -45,23 +54,18 @@ private void StopAnimation()
4554
LeanTween.cancel(tween);
4655
// Doubly cancel since the first doesn't seem to work (?)
4756
LeanTween.cancel(content.gameObject);
48-
content.padding.Remove(new Rect());
49-
content.padding.top = initialTopPadding;
57+
content.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, initialInset, content.rect.height);
5058
}
5159

5260
private void SetPosition(float t)
5361
{
54-
var topPadding = Mathf.RoundToInt(initialTopPadding - height * t);
55-
content.padding = new RectOffset(content.padding.left, content.padding.right, topPadding,
56-
content.padding.bottom);
62+
var inset = Mathf.RoundToInt(initialInset - height * t);
63+
content.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, inset, content.rect.height);
5764
}
5865

5966
public void SetPlayerInput(InputManager inputManager)
6067
{
6168
this.inputManager = inputManager;
62-
inputManager.onCancel += Back;
63-
inputManager.onSelect += Back;
64-
inputManager.onClick += Back;
6569
}
6670

6771
private void Back(InputAction.CallbackContext ctx)
Loading

Assets/Textures/Props/SprayCan/PremadeSprays/SprayBoomSprite.png.meta

+124
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Loading

Assets/Textures/Props/SprayCan/PremadeSprays/SprayCactusSprite.png.meta

+124
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Loading

0 commit comments

Comments
 (0)