39 lines
1.1 KiB
C#
39 lines
1.1 KiB
C#
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;
|
|
img.raycastTarget = true;
|
|
|
|
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
|
|
);
|
|
}
|
|
}
|
|
}
|