- Home /
UI is turning invisible every time i run my game
I keep running my game and the UI turns invisible every time. There's nothing in my code that could be doing this. The problem might have to do with a image covering the entire canvas but the image is full alpha. There is no way that one image could make the rest invisible. And no the other bits of the ui are not children of the big image. I think this is a bug because it fixes every time i re-import assets...but then it breaks again. Plz help. :(
Also the big transparent image turns invisible as well. Like even if i change the alpha through the inspector it still is invisible.
can you please give us more informations like picture of your screen and a picture of your UI Inspector ?
is it possible that the renderer is disabled or even the object itself?
Nope. If i reload the assets and/or close and open the project it'll be visible again. That is until i run the game again.
I think there's something which is changing the color which is making it transparent permanently, because after you re-import the assets it's ok, but after you run it again for the first time it is permanently not. Look at what happened to the material itself in the inspector after after you have done a fresh re-import and again after a play through.
I know this occurred for me when I used 'sharedmaterial' ins$$anonymous$$d of 'material' in $$anonymous$$eshRenderer.
Answer by Gaming-Dudester · Nov 30, 2016 at 11:35 PM
Ok so for some weird reason...i think this script made the problem. as soon as i took it off the problem stopped. Heres the script.
using UnityEngine; using System.Collections; using UnityEngine.UI; using UnityEngine.SceneManagement; public class Fade : MonoBehaviour {
public float alpha = 0.1f;
public Color color;
public GameObject fadeOutObject;
public bool triggerFade;
public float fadeOutSpeed;
void Update ()
{
if (triggerFade == true)
{
alpha += fadeOutSpeed;
}
color.a = alpha;
fadeOutObject.GetComponent<Image>().material.color = color;
}
}
i dont know if this is the actual cause but i think for now i will hold off on the fade script
and no...the fade out object was the big black thing. it was not the ui because if it was then it would only be effected at runtime. Which this problem did not.
Answer by Denscrivent · Dec 01, 2016 at 08:14 AM
From the script you showed, there is:
public float alpha = 0.1f;
then inside Update, you have
color.a = alpha; fadeOutObject.GetComponent().material.color = color;
that makes the object faded I think
Your answer
Follow this Question
Related Questions
Renderer on object disabled after level reload 1 Answer
[Solved] Buttons become invisible when scaling game view 1 Answer
Adding a ui text as a child of canvas disables all child buttons and makes them break 1 Answer
Unity Rendering Some Images, But Not Others (World Space UI) 1 Answer
Workaround for UI render to texture bug 0 Answers