added and tweaked settings panel tweens/buttons

This commit is contained in:
Xevion
2020-05-21 10:11:08 -05:00
parent 94cd9fae77
commit dcbcd3ffa7
3 changed files with 978 additions and 7 deletions
@@ -94,9 +94,9 @@ Material:
- _FaceUVSpeedX: 0 - _FaceUVSpeedX: 0
- _FaceUVSpeedY: 0 - _FaceUVSpeedY: 0
- _GlowInner: 0.05 - _GlowInner: 0.05
- _GlowOffset: 0 - _GlowOffset: -1
- _GlowOuter: 0.05 - _GlowOuter: 0.05
- _GlowPower: 0.75 - _GlowPower: 0.08
- _GradientScale: 6 - _GradientScale: 6
- _LightAngle: 3.1416 - _LightAngle: 3.1416
- _MaskSoftnessX: 0 - _MaskSoftnessX: 0
File diff suppressed because it is too large Load Diff
+36 -2
View File
@@ -20,6 +20,10 @@ public class UIController : MonoBehaviour {
// Adjustment Panel Elements // Adjustment Panel Elements
public RectTransform adjPanel; public RectTransform adjPanel;
// Settings Panel Elements
public RectTransform settingsPanel;
public Button settingsCloseButton;
// Element Groups // Element Groups
private GameObject[] _titleElements; private GameObject[] _titleElements;
@@ -53,18 +57,21 @@ public class UIController : MonoBehaviour {
startButton.onClick.AddListener(OnStartButton); startButton.onClick.AddListener(OnStartButton);
aboutButton.onClick.AddListener(OnAboutButton); aboutButton.onClick.AddListener(OnAboutButton);
aboutCloseButton.onClick.AddListener(OnAboutClose); aboutCloseButton.onClick.AddListener(OnAboutClose);
// settingsButton.onClick.AddListener(OnSettingsButton); settingsButton.onClick.AddListener(OnSettingsButton);
settingsCloseButton.onClick.AddListener(OnSettingsCloseButton);
// Calculate UI position deltas // Calculate UI position deltas
_aboutDiff = new Vector3(_canvasRect.size.x * _scaleFactor, 0, 0); _aboutDiff = new Vector3(_canvasRect.size.x * _scaleFactor, 0, 0);
_aboutButtonDiff = new Vector3(75 * _scaleFactor, 0, 0); _aboutButtonDiff = new Vector3(75 * _scaleFactor, 0, 0);
_titleDiff = new Vector3(0, 450 * _scaleFactor, 0); _titleDiff = new Vector3(0, 450 * _scaleFactor, 0);
_adjustmentsDiff = new Vector3(adjPanel.rect.size.x * _scaleFactor, 0, 0); _adjustmentsDiff = new Vector3(adjPanel.rect.size.x * _scaleFactor, 0, 0);
_settingsDiff = new Vector3(_canvasRect.size.x * _scaleFactor * -1,0, 0);
// Move UI elements into position // Move UI elements into position
Vector3 center = canvas.transform.position; Vector3 center = canvas.transform.position;
aboutPanel.transform.position = center + _aboutDiff; aboutPanel.transform.position = center + _aboutDiff;
adjPanel.transform.position = center + new Vector3((_canvasRect.size.x + 10) / 2f * _scaleFactor, 0, 0) + _adjustmentsDiff / 2f; adjPanel.transform.position = center + new Vector3((_canvasRect.size.x + 10) / 2f * _scaleFactor, 0, 0) + _adjustmentsDiff / 2f;
settingsPanel.transform.position = center + _settingsDiff;
// Group Element Instantiation // Group Element Instantiation
_titleElements = new[] {titleText.gameObject, startButton.gameObject, settingsButton.gameObject}; _titleElements = new[] {titleText.gameObject, startButton.gameObject, settingsButton.gameObject};
@@ -102,12 +109,39 @@ public class UIController : MonoBehaviour {
.setEase(away ? LeanTweenType.easeInCubic : LeanTweenType.easeOutCubic); .setEase(away ? LeanTweenType.easeInCubic : LeanTweenType.easeOutCubic);
} }
private void MoveSettingsElements(bool away) {
LeanTween
.move(settingsPanel.gameObject, settingsPanel.transform.position + _settingsDiff * (away ? 1 : -1),
away ? 0.7f : 1.1f)
.setDelay(away ? 0.05f : 0.15f)
.setEase(away ? LeanTweenType.easeInCubic : LeanTweenType.easeOutCubic);
}
// Handle switching to the Play Screen // Handle switching to the Play Screen
private void OnStartButton() { private void OnStartButton() {
if (_currentUI == UIStance.Title) { if (_currentUI == UIStance.Title) {
Debug.Log($"UI Transition: {_currentUI} -> {UIStance.About}"); Debug.Log($"UI Transition: {_currentUI} -> {UIStance.About}");
MoveTitleElements(true); MoveTitleElements(true);
MoveAdjustmentElements(false); MoveAdjustmentElements(false);
_currentUI = UIStance.Play;
}
}
private void OnSettingsButton() {
if (_currentUI == UIStance.Title) {
Debug.Log($"UI Transition: {_currentUI} -> {UIStance.Settings}");
MoveTitleElements(true);
MoveSettingsElements(false);
_currentUI = UIStance.Settings;
}
}
private void OnSettingsCloseButton() {
if (_currentUI == UIStance.Settings) {
Debug.Log($"UI Transition: {_currentUI} - > {UIStance.Title}");
MoveTitleElements(false);
MoveSettingsElements(true);
_currentUI = UIStance.Title;
} }
} }