ok am very new to this, so sorry for posting (and hope this is the right place) but have also spent ages looking for answers and nothing springs to mind.
Here’s my code…
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class Menu : MonoBehaviour
{
public Image im;
public bool faded = false;
void Awake()
{
}
void Update()
{
if (faded == false)
{
faded = true;
print("Entering Co-Routine");
StartCoroutine(MyTest());
}
}
public void PlayButton()
{
SceneManager.LoadScene("E1M1");
}
IEnumerator MyTest()
{
print("Got Into Co-Routine");
yield return new WaitForSeconds(5);
im.enabled = false;
print("Exiting Co-Routine");
}
}
I have no errors, and when it runs I get the first two print messages (“Entering Coroutine” and “Got Into Co-Routine”, but the image never disables and the “Exiting Co-routine” message never shows.
I am sure I am doing something really stupid and basic, but would appreciate the help because it seems so basic and I have done this before no issues.
The script is attatched to a game object on a UI canvas (not that of the image being disabled).
In case it is of any use… I tried Invoke and that didn’t work either
This is my code for the Invoke version…
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class Menu : MonoBehaviour
{
public Image im;
public bool faded = false;
void Awake()
{
}
void Update()
{
if (faded == false)
{
faded = true;
print("Entering Invoke");
Invoke("MyTest", 4);
}
}
public void PlayButton()
{
SceneManager.LoadScene("E1M1");
}
void MyTest()
{
print("Got Into Invoke");
im.enabled = false;
print("Completing Invoke");
}
}
This version again has no errors and prints the “Entering Invoke” message but then stops.
Regards
Moria