I’m setting up a Main Menu and we have a video we want to skip through when we return to the menu from game. For some reason I’m not sure why when I try to update the frame within the start function it doesn’t recognised that I have changed the frame.
Code to Return to the Main Menu
IEnumerator SceneMainMenu()
{
// Set Load Panel To active
loadingScreenObj.SetActive(true);
async = SceneManager.LoadSceneAsync("Main_Menu");
async.allowSceneActivation = false;
Time.timeScale = 1f;
returnToMainMenu = "Yes";
PlayerPrefs.SetString("Return", returnToMainMenu);
while (async.isDone == false)
{
slider.value = async.progress;
if (async.progress == 0.9f)
{
slider.value = 1f;
async.allowSceneActivation = true;
}
yield return null;
}
}
Main Menu Code In Question
void Start()
{
int startFrame = 0;
float i = 17;
returnFromInGame = PlayerPrefs.GetString("Return", "No");
Debug.Log(returnFromInGame);
if (returnFromInGame == "Yes")
{
startFrame = 445;
i = 1;
}
SetupCoroutine(i, startFrame);
PlayerPrefs.DeleteKey("Return");
}
private void SetupCoroutine(float i , int j)
{
Debug.Log("Coroutine Runtime : "+ i);
Debug.Log("frame to skip to : "+j);
MenuVid.GetComponent<VideoPlayer>().frame = j;
StartCoroutine(ButtonAnimationTime(i));
Debug.Log("Current Frame : "+ MenuVid.GetComponent<VideoPlayer>().frame);
}
IEnumerator ButtonAnimationTime(float i)
{
for (int j = 0; j < buttonList.Count; j++)
{
buttonList[j].SetActive(false);
}
yield return new WaitForSeconds(i);
for (int j = 0; j < buttonList.Count; j++)
{
buttonList[j].SetActive(true);
}
}