Is there any other method to pause a game apart from using Time.timescale=0; ?,Can I pause my game other than setting Time.timeScale = 0;

Hi everyone, I am a 17 yr old novice programmer and have a hard time creating a fully functional pause menu. My issue is that the only thing my code can do is to freeze the time but not the touch input for the player into the game itself. A clearer example is that I can pause the game and nothing moves at all but if I press anywhere else in the game screen apart from the buttons severally and then I resume the game, the player receives all of those inputs (the inputs after tapping many times when it was paused) at once causing it to move uncontrollably and crashes in walls unexpectedly and dies. I don’t know if it is possible to disable touch screen functionality (except for the navigation buttons) using code. By the way, the game play moves the player not with buttons but with touch just like Subway Surfers or Angry Birds. Here is the code. I’ll appreciate any help I can get. Thanks for your time.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Pause : MonoBehaviour
{
    public GameObject PauseButton, PausePanel; //References the pause button and pause menu

    public void OnPause()
    {
        Time.timeScale = 0;//Freezes time but not game player input
        PauseButton.SetActive(false);//Disables the pause button when game is paused
        PausePanel.SetActive(true);//Enables the pause menu when game is paused
    }

    public void OnUnPause()
    {
        Time.timeScale = 1;//Unfreezes time when game is resumed
        PauseButton.SetActive(true); //Re-enables pause button during gameplay after resuming
        PausePanel.SetActive(false);//Disables pause menu
    }
}

,Hello everyone. I am a 17-year old novice programmer and having a hard time to pause my game. The issue is that after pressing the pause button on the game screen, the game stops only the time but not user input inside the game. A clearer example is that when I pause the game, I can tap anywhere else on the screen other than the resume button, when I finally press the resume or main menu button to resume, the game receives the multiple touches I had input while it was paused and translates these touches to cause the player to move everywhere as if I have pressed the screen a hundred times at once during gameplay. Is there a way to disable touch input for the game completely (but still enable touch input for the “Resume” and “Back to Main Menu” buttons) when the game is paused so that it won’t execute all of those inputs at that moment when I resume the game? I’ll appreciate any help.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Pause : MonoBehaviour
{
    public GameObject PauseButton, PausePanel;  //To reference the Pause button and Pause panel

    public void OnPause()
    {
        Time.timeScale = 0;//Freezes time only during pause but game's player still receives input
        PauseButton.SetActive(false);  //Disables the pause button on the screen when game is paused
        PausePanel.SetActive(true);  //Enables the panel which contains the "Resume" and "Main menu" 
    }

    public void OnUnPause()
    {
        Time.timeScale = 1; //Unfreezes the game when "Resume" is pressed 
        PauseButton.SetActive(true); //Re-displays the pause button when game resumes 
        PausePanel.SetActive(false); //Disables the pause menu
    }
}

You could try an event system or have your control scripts disable themselves when the game is paused. Maybe you could disable those scripts in that script. They still receive inputs, but since time is frozen, everything it tried happens at once.

Disable graphic raycaster component in canvases that control movement