Canvas Error - Everything tinted blue
So whenever I play this scene in the editor - or in the built version, I open up a canvas object and all of a sudden everything in the canvas gets tinted blue. But then when I goto other scenes, all the canvases there are tinted blue as well. It does not reset until I quit and reopen Unity. It is triggered when a certain panel in enabled in just this one scene but affects the rest of the canvases in the project. Any ideas? I am on the latest version of Unity, 5.2.1f1
In the picture below, notice how yellow text appears dark blue.
Answer by MikeChurvis · Mar 06, 2016 at 02:49 AM
@Brainrush1 Howdy! Not sure if you're still having this issue, but the same thing just happened to me. Somewhere in a script, I had done this:
void SetColor(Color newColor)
{
canvasElement.material.color = newColor;
...
}
The problem with this is twofold:
Canvas elements have a default shared material called "none" (yes, "none" is an actual material, not the absence of one). When you modify
canvasElement.material.color
you're changing the "none" material's color, meaning you're changing the color of every canvas element with the "none" material.This change persists even after you've quit out of the game, meaning it doesn't automatically reset like most other in-game changes do.
To fix this,
Comment out or Remove any code that's similar to the problem code above (tip: Command/Control + F for "material.color").
put this C# script on an empty gameObject in the scene:
using UnityEngine; using UnityEngine.UI; public class MaterialFixer : MonoBehaviour { // When the game starts, void Awake() { // Add an Image component to this GameObject Image canvasElement = gameObject.AddComponent<Image>(); // and change the Image's material, shared between all canvas elements, back to white. canvasElement.material.color = Color.white; } }
Hit the Play button. The color of all Canvas elements should return to normal and stay that way. You can now safely remove the script.
Let me know if this helps, or if you have any other issues. Cheers!
- Mike Churvis
Thanks for the thorough response, as it turns out, the default material on the canvas was being set by some script an old coworker had written - took away that script and everything was ok. Thanks a lot though, $$anonymous$$ike.
-Pablo Leon-Luna
Answer by AmirMM_333 · Dec 20, 2019 at 12:44 PM
Just right click on the "Default UI Material" and select Reset. done.
Your answer
Follow this Question
Related Questions
Working with UI makes both editor and game view jump between 1x and 2x scale. 1 Answer
Canvas is scaling in the editor but not in the build 1 Answer
Unable to create a coloured mesh on a canvas. 1 Answer
How can I change the UI button color when clicked 1 Answer
[SOLVED] Image is not visible in Panel (in game view) 0 Answers