Added basic scene transition
This commit is contained in:
37
Assets/Scripts/Game/SceneControllerTransition.cs
Normal file
37
Assets/Scripts/Game/SceneControllerTransition.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Fruitomation.Game
|
||||
{
|
||||
public class SceneControllerTransition : MonoBehaviour
|
||||
{
|
||||
private RectTransform CanvasRect;
|
||||
private Canvas AttachedCanvas;
|
||||
private RectTransform Rect;
|
||||
|
||||
public float LerpValue;
|
||||
public bool GoingUp;
|
||||
|
||||
public void OnCreation(Canvas canvas)
|
||||
{
|
||||
Image img = gameObject.AddComponent<Image>();
|
||||
img.color = Color.black;
|
||||
|
||||
CanvasRect = canvas.GetComponent<RectTransform>();
|
||||
Rect = transform.GetComponent<RectTransform>();
|
||||
AttachedCanvas = canvas;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
Rect.anchoredPosition = GoingUp
|
||||
? new Vector2(0, +(CanvasRect.sizeDelta.y / 2f))
|
||||
: new Vector2(0, -(CanvasRect.sizeDelta.y / 2f));
|
||||
Rect.sizeDelta = new Vector2
|
||||
(
|
||||
CanvasRect.sizeDelta.x,
|
||||
CanvasRect.sizeDelta.y * LerpValue * 2f
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user