[Solved] Glitch Garden - Text displaying under defenders / attackers

Hi Guys,

Hopefully someone will be able to figure this one out. I have added a Pause function to the Glitch Garden game I am creating however when the pause button is pressed the text does not display on top of the defenders / attackers in the core game area. Does anyone have an idea on how to do this. Also the pause text doesn’t display on the first Pause event though will on the 2nd. I have done this through to sprites with 2d box colliders on them. Which both have this script attached. I tried changing the sprite on a single game object and this caused issues with scaling of the sprite would reduced the size of the 2d box collider. I have tried playing with the z index of its transform without much luck.

Thanks Pete

    public class PauseButton: MonoBehaviour
    {
        public Text pausedText;
        public static bool pause = false;
        public GameObject playBtn;
        public GameObject pauseBtn;
        void Start()
        {
            pausedText.enabled = false;
        }
        public void PauseGame() {
            pause = !pause;
            if (pause) {
                Time.timeScale = 0f;
                pausedText.enabled = true;
                pauseBtn.SetActive(false);
                playBtn.SetActive(true);
            } else {
                Time.timeScale = 1f;
                pausedText.enabled = false;
                playBtn.SetActive(false);
                pauseBtn.SetActive(true);
            }
        }
        void OnMouseDown() {
            PauseGame ();
        }
    }

It may be related to the canvas.

Might be worth a try to check on, could you go to the Canvas -> Render Mode and check this is set to ‘Screen Space - Camera’?

Hopefully this works, that’s my only thought on how to fix it :pray:

Thanks pokedev8,

I had a look at this and I couldn’t get this to work so I gave up and made the text a sprite using gimp and was able to move it forward by using the sorting layer of the object. However since trying to change the render mode of the canvas I have broken the coordinate system of the defender spawner. Now I am going to have pull that apart to figure out what has changed. I think it might be time for me to use bitbucket in order to get some change monitoring.

1 Like