add adjustments panel tween and auto positioning

This commit is contained in:
Xevion
2020-05-21 09:54:49 -05:00
parent 94ae4bb5bc
commit 94cd9fae77
2 changed files with 23 additions and 9 deletions

View File

@@ -890,7 +890,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0.000022888, y: -0.0000019073}
m_AnchoredPosition: {x: 1068.0009, y: 0}
m_SizeDelta: {x: -400, y: -130}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &882182195
@@ -964,7 +964,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 190.47, y: -55.5}
m_AnchoredPosition: {x: 292.7, y: -84.7}
m_SizeDelta: {x: 40, y: 35}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1009112610
@@ -989,7 +989,7 @@ MonoBehaviour:
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 12800000, guid: 43d6a52fcfa8f28419b2edb41d50e5c0, type: 3}
m_FontSize: 15
m_FontSize: 19
m_FontStyle: 1
m_BestFit: 0
m_MinSize: 0
@@ -1332,8 +1332,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: -86.45}
m_SizeDelta: {x: 369.99, y: 172.72}
m_AnchoredPosition: {x: 12, y: -146}
m_SizeDelta: {x: 561.2, y: 268.22}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1363541045
MonoBehaviour:
@@ -1357,11 +1357,11 @@ MonoBehaviour:
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_FontData:
m_Font: {fileID: 12800000, guid: 43d6a52fcfa8f28419b2edb41d50e5c0, type: 3}
m_FontSize: 137
m_FontSize: 211
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 0
m_MaxSize: 137
m_MaxSize: 255
m_Alignment: 0
m_AlignByGeometry: 0
m_RichText: 1

View File

@@ -17,6 +17,9 @@ public class UIController : MonoBehaviour {
public RectTransform aboutPanel;
public Button aboutCloseButton;
// Adjustment Panel Elements
public RectTransform adjPanel;
// Element Groups
private GameObject[] _titleElements;
@@ -56,10 +59,13 @@ public class UIController : MonoBehaviour {
_aboutDiff = new Vector3(_canvasRect.size.x * _scaleFactor, 0, 0);
_aboutButtonDiff = new Vector3(75 * _scaleFactor, 0, 0);
_titleDiff = new Vector3(0, 450 * _scaleFactor, 0);
_adjustmentsDiff = new Vector3(adjPanel.rect.size.x * _scaleFactor, 0, 0);
// Move UI elements into position
aboutPanel.transform.position = canvas.transform.position + _aboutDiff;
Vector3 center = canvas.transform.position;
aboutPanel.transform.position = center + _aboutDiff;
adjPanel.transform.position = center + new Vector3((_canvasRect.size.x + 10) / 2f * _scaleFactor, 0, 0) + _adjustmentsDiff / 2f;
// Group Element Instantiation
_titleElements = new[] {titleText.gameObject, startButton.gameObject, settingsButton.gameObject};
}
@@ -81,6 +87,13 @@ public class UIController : MonoBehaviour {
.setEase(LeanTweenType.easeInOutCubic);
}
private void MoveAdjustmentElements(bool away) {
LeanTween
.move(adjPanel.gameObject, adjPanel.gameObject.transform.position + _adjustmentsDiff * (away ? 1 : -1), 1.15f)
.setDelay(away ? 0f : 0.15f)
.setEase(LeanTweenType.easeInOutCubic);
}
// Move About Elements In/Out
private void MoveAboutElements(bool away) {
LeanTween
@@ -94,6 +107,7 @@ public class UIController : MonoBehaviour {
if (_currentUI == UIStance.Title) {
Debug.Log($"UI Transition: {_currentUI} -> {UIStance.About}");
MoveTitleElements(true);
MoveAdjustmentElements(false);
}
}