Gave an exit animation to windows
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
namespace InterfaceOff
|
||||
@@ -55,14 +56,30 @@ namespace InterfaceOff
|
||||
Components.RectTransform.anchoredPosition = position; // Updates position if it is supposed to change
|
||||
}
|
||||
|
||||
public virtual void OnWindowInstantiation() { }
|
||||
protected virtual void OnWindowInstantiation() { }
|
||||
|
||||
/* Default close button closes the window */
|
||||
public virtual void OnWindowCloseButtonClicked() => DestroyWindow();
|
||||
|
||||
public void DestroyWindow()
|
||||
{
|
||||
StartCoroutine(routine: DeathSequence());
|
||||
Creator.AlertOfDespawnedWindow();
|
||||
}
|
||||
|
||||
private IEnumerator DeathSequence()
|
||||
{
|
||||
float duration = 0f;
|
||||
while (duration < 1f)
|
||||
{
|
||||
duration += Time.deltaTime;
|
||||
float scale = 1f - duration;
|
||||
|
||||
transform.localScale = new Vector3(scale, scale, 1f);
|
||||
|
||||
yield return null;
|
||||
}
|
||||
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user