I have a button in my scene that I will need to check if it was clicked. If the button as clicked and if the videoPlayer frame is at 350 I want to change the scene. I have the videoframe part figured out, I just need to check if the button was clicked.
Here is my handle button that is attached to a standard On Click UI Button.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HandleButton : MonoBehaviour
{
public static bool clicked = false;
void LateUpdate()
{
clicked = false;
}
public void Click()
{
clicked = true;
// Debug.Log("CLICKED");
}
}
And here is the script that will check the video player frame and if the button was pressed.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;
public class operationsTentButtonScript : MonoBehaviour
{
HandleButton handleButton;
VideoPlayer vp;
void Start()
{
vp = GetComponentInParent<VideoPlayer>();
vp.Play();
handleButton = GetComponent<HandleButton>();
}
void Update()
{
if (vp.frame == 350 && HandleButton.clicked == true)
{
//Debug.Log("TEST");
UnityEngine.SceneManagement.SceneManager.LoadScene("operationsTentSeq");
}
}
}
The line in question is this " if (vp.frame == 350 && HandleButton.clicked == true) "
What am I doing wrong please. It is driving me crazy lol
Thanks for your reply. I want to change scene precisely at frame 350 which first part of the code works just fine.
If I have just the following it automatically triggers the SceneManager.LoadScene at frame 350. I just need to add the second condition (was the button pressed) in the if statement. Basically eventually this should do the following; if they have pressed it it will load a difference then if they have not at frame 350.
if (vp.frame == 350)
{
//Debug.Log("TEST");
UnityEngine.SceneManagement.SceneManager.LoadScene("operationsTentSeq");
}