59 lines
1.3 KiB
C#
59 lines
1.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.SceneManagement;
|
|
|
|
public class GiveUpBtnBehaviour : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
|
|
{
|
|
public Image loadImg;
|
|
private float filledPc = 0;
|
|
private bool isHolding = false;
|
|
public bool returnToMainMenu = false;
|
|
public void Awake()
|
|
{
|
|
|
|
}
|
|
|
|
public void FixedUpdate()
|
|
{
|
|
if (isHolding)
|
|
{
|
|
if (filledPc < 1)
|
|
{
|
|
filledPc += Time.deltaTime;
|
|
}
|
|
else if (filledPc >= 1)
|
|
{
|
|
if (returnToMainMenu)
|
|
{
|
|
SceneManager.LoadScene(1, LoadSceneMode.Single);
|
|
|
|
}
|
|
else
|
|
{
|
|
SceneManager.LoadScene(9, LoadSceneMode.Single);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
else if (filledPc > 0)
|
|
{
|
|
filledPc -= Time.deltaTime;
|
|
}
|
|
loadImg.fillAmount = filledPc;
|
|
}
|
|
|
|
public void OnPointerDown(PointerEventData data)
|
|
{
|
|
isHolding = true;
|
|
}
|
|
|
|
public void OnPointerUp(PointerEventData data)
|
|
{
|
|
isHolding = false;
|
|
}
|
|
}
|