My Button Doesn’t Work.
The function doesn’t show up in the on click thing
My code is as follows
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class DetectIfParked : MonoBehaviour
{
[SerializeField] RectTransform fader;
public GameObject level1Passed;
bool isColliding = false;
void Start()
{
level1Passed.SetActive(false);
}
void OnCollisionEnter(Collision col)
{
if (col.gameObject.tag == "Objective")
{
isColliding = true;
StartCoroutine(TimerStart());
Debug.Log("Started Coroutine");
}
}
void OnCollisionExit()
{
isColliding = false;
Debug.Log(isColliding);
}
void EndCoroutine()
{
StopCoroutine(TimerStart());
}
IEnumerator TimerStart()
{
yield return new WaitForSeconds(2);
Debug.Log(isColliding);
if(isColliding == true)
{
Level1Passed();
}
else
{
Debug.Log("Ending Coroutine");
EndCoroutine();
}
}
public void Level1Passed()
{
level1Passed.SetActive(true);
Time.timeScale = 0f;
}
public void LoadLevel2()
{
fader.gameObject.SetActive(true);
LeanTween.scale(fader, Vector3.zero, 0f);
LeanTween.scale(fader, new Vector3(1,1,1), 0.5f).setEase(LeanTweenType.easeInOutExpo).setOnComplete(() =>
{
Invoke("Level2", 0.5f);
});
}
private void Level2()
{
SceneManager.LoadScene(3);
}
}
The Scene I need to load is Scene 3
Thank You