- Home /
Text mesh is darker after scene restart
Hi all,
I'm having a very strange issue with the main menu scene (simply called "Menu") in the game I'm working at.
When the game starts, a basic animation is run on the 3D game title.
If, during the game, the player chooses to go back to the main menu, I load back the main scene, the animation starts again but this time the title is oddly dark.
In order to simplify the analysis, I've stripped back the main title script until I came to this code:
public class TitleAnimation : MonoBehaviour {
public GameObject menu;
void Start () {
menu.SetActive (false);
}
void Update () {
Vector3 scale = new Vector3 (1, 1, Mathf.Lerp (0, 15, Time.timeSinceLevelLoad));
transform.localScale = scale;
if (Time.timeSinceLevelLoad > 2)
Application.LoadLevel("Menu");
menu.SetActive (true);
}
}
'menu' is a UI panel that should become active only after the animation has ended.
In theory, the same same animation should be drawn each time the level is restarted. In practice, the first time after game start the title is correctly lit, while after each following restart the title is noticeably darker. All the lights are still active and seem to be working correctly. It's as if, at first start, an additional light source was present on the scene.
Another weird issue is that, with the sample code I've written above, the 'menu' panel is actually visible right from the start, as if the menu.SetActive (false) instruction was ignored. It's not visible if I remove the line menu.SetActive (true); at the end of Update(), which in theory should never be reached. This is not a major issue however, I just discovered it by accident while simplifying the code.
Any idea on what might be happening?
It seems its a bug in the editor with GI and light-backing after changing / loading a new scene. But this should only be in the editor and not the exported game.