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.
@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();
// 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
Just right click on the “Default UI Material” and select Reset.
done.