Toggle drag objects

Manipulating draggable and pickup objects normally requires the input button to be held down for the duration. This script allows you to toggle "drag mode" on and off with separate button presses.

To use it: ToggleDrag.cs: using UnityEngine; using AC; public class ToggleDrag : MonoBehaviour { 	public string toggleDragInput = "ToggleDrag"; private bool waitForUp; private bool pressedThisFrame; private void Start { 		KickStarter.playerInput.dragOverrideInput = toggleDragInput; KickStarter.playerInput.InputGetButtonDelegate = My_InputGetButton; } 	private void OnEnable { 		EventManager.OnGrabMoveable += ResetInput; EventManager.OnDropMoveable += ResetInput; } 	private void OnDisable { 		EventManager.OnGrabMoveable -= ResetInput; EventManager.OnDropMoveable -= ResetInput; } 	private void LateUpdate { 		pressedThisFrame = Input.GetButtonDown (toggleDragInput); } 	private bool My_InputGetButton (string axisName) { 		try { 			if (axisName == toggleDragInput) { 				if (!KickStarter.playerInput.IsDragObjectHeld ) { 					return pressedThisFrame; } 				else { 					if (pressedThisFrame) { 						KickStarter.playerInput.LetGo ; return false; } 					return true; } 			}  			return Input.GetButton (axisName); } 		catch {} return false; } 	private void ResetInput (DragBase dragBase) { 		pressedThisFrame = false; } }
 * 1) Define a new Input axis in Unity's Input Manager named ToggleDrag, and map it to the button(s) of your choice
 * 2) Paste the code below into a C# file named ToggleDrag, and attach to an empty GameObject in your scene