Temporarily disable gamepad button

Good morning (afternoon, evening, fill in the blank)

Am wondering if there is a way to disable a gamepad button in certain contexts. (I did search, only found things about GUI Buttons)

For instance: when the player enters into a conversation, I’d like the pause menu button to be disabled. Currently it is mapped to what would be the circle button on a PS3 controller. (don’t worry about specifics there, only used PS3 controller as an example, it’s actually a Logitech f310)

Thanks for any and all help / advice / points in the right direction. God bless.

When you enter a conversation/cutscene/whatEverItIsThatYou’reTryingToDisableInputFor, set a boolean acceptInput to false. When your process your input (your circle button for example) check to make sure that acceptInput is true before you do the processing, otherwise return.

public bool acceptInput = true;

void EnterConversation()
{
  acceptInput = false;
  // code...
}

void ProcessInput()
{
   if (!acceptInput) 
       return;
   if (circle button is pressed)
   {
       Pause();
   }
   else if (....)
}

And of course, don’t forget to set it back to true when the conversion is over.

I appreciate your feedback on my answer.

EDIT: I didn’t really wanna tidy up your script, instead I put some comments here and there just to let you know what redundancies you have, I thought it’s more educational this way. So take the hints and things I pointed out for you, modify your actual scripts and then if you still have any questions add the modified scripts as an edit to your question. And please work on your formatting skills.

public class UrusalimShop1DialogueCameraSwitch : MonoBehaviour
{
	public bool acceptInput = true;
	 
	// consider using arrays instead of separate variables, what if at one point you decided to and another camera, and another and another, etc
	// this would get really messy pretty quick
	// i'd use a public Camera[] cams;
	// and then make a property for the first cam (since you're using it a lot)
	// public Camera FirstCam {private set {cams[0] = value;} get {return cams[0];}}
	public Camera camera1;
	public Camera camera2;
	public Camera camera3;
	 
	// you don't actually need this variable, because you're setting it to true when camera1.active is true, and false when it's false
	// so it's basically the same thing as camera1.active
	// in other words, in your calcuations, just use if (camera1.active) instead of (camera1ActiveBool)
	bool camera1ActiveBool;
	 
	void Start ()
	{
		acceptInput = false;
		//camera1.camera.active = true;  no need to access the camera component from your camera1 object, since it's already a camera :)
		camera1.active = true;
		camera2.active = false;
		camera3.active = false;
		camera1ActiveBool = true;
	}
	 
	void OnTriggerEnter (Collider other)
	{
		if (other.gameObject.tag == "Player")
		{
			// you don't need to say if (x == true)
			// the way conditional statements work is, they take a boolean expression, which is anything that returns either true or false.
			// for example: 1 > 2 (returs false), 10 == 10 (returns true).
			// Now, since the boolean expression itself returns a true/false, I don't need to say if ((10 == 10) == true), that's like saying if (true == true), which turns to if (true).
			// in other words, since camera1ActiveBool is a boolean (something that returns true/false) you don't need to say:
			// if (camera1ActiveBool == true), if you wanted to check if it was false, you just negate it with the pound sign:
			// if (!camera1ActiveBool)

			if (camera1ActiveBool)
			{
				// setting component.active = boolean; will either activiate/deactiviate the gameObject that has this component
				// setting component.enabled = boolean; (like a script for example) will only enable/disable that component, and won't affect the gameObject its attached to
				// in other words, if you have a script, attached to a gameObject and you wanted to disable the whole gameobject (which will in turn disable the functionality of the script as well), use myScript.active = false; or myScript.gameObject.active = false; (same thing)
				// but if you wanted to ONLY disable that script, you'd do myScript.enabled = false;
				// So, if the gameObject that has your camera component doesn't have any other componet beside the camera, you could just do
				// cameraN.gameObject.SetActive(boolean) (don't use camera1.active, it's obselete, deprecated)
				// otherwise cameraN.enabled = boolean;
				// in other words, you don't need to use both enabled and active at the same time.

				camera1.active = false;
				camera2.active = true;
				camera2.enabled = true;
				camera1.enabled = false;
				camera3.enabled = false;
				camera1ActiveBool = false;
				 
				Time.timeScale = 0;
			}
			 
			// no need for the else-if here, a boolean could either be true or false, you just need a simple if-else statement here. 
			// you'd use an else-if for something, that could have more than 2
			// values, like if (player.state == state.walking) { } else if (player.state == state.idle) { } else if (player.state == state.attacking) etc
			// else if (camera1ActiveBool == false)
			else
			{
				camera1.active = true;
				camera2.active = false;
				camera1.enabled = true;
				camera2.enabled = false;
				camera3.enabled = true;
				 
				camera1ActiveBool = true;
				Time.timeScale = 1;
			}
		}
	}

Pause Menu Switch

	using UnityEngine;
	using System.Collections;
	 
	public class Menu : MonoBehaviour
	{
	 
		public Camera camera1;
		public Camera camera2;
		bool camera1ActiveBool;
		 
		void Start ()
		{
			camera1.active = true;
			camera2.active = false;
			camera1ActiveBool = true;
		}
		 
		 
		void Update ()
		{
			//use whatever button you want to toggle
			if(Input.GetButtonDown("Inventory"))
			{
			 
				// this whole logic is redundant, notice how it's repitive, and the values are kinda the opposite?
				//if (camera1ActiveBool)
				//{
					//camera1.active = false;
					//camera2.active = true;
					//camera1ActiveBool = false;
					//Time.timeScale = 0;
				//}
				//else
				//{
					//camera1.active = true;
					//camera2.active = false;
					//camera1ActiveBool = true;
					//Time.timeScale = 1;
				//}

				// all you need to do is:
				camera1.active = !camera1ActiveBool;	// this means, if cam1ActBool was true, then !cam1ActBool is false, thus camera1.active = false;
				camera2.active = camera1ActiveBool;
				camera1ActiveBool = !camera1ActiveBool; // toggle it, change it to the opposite state
				Time.timeScale = camera1ActiveBool ? 0 : 1; // this is called the ternary operator, its equivalent would be if (camActiveBool) timescale = 0; else timeScale = 1;

				// use the same type of reduction on the previous if-else statement, (in the previous script)
				// didn't wanna do it for you cause I thought it'd be nice if you practise it yourself
			}
		}
	}