using System; using UnityEngine; public class ControlSwitch : MonoBehaviour { public KeyCode toggleKey = KeyCode.C; public GameObject manualController; public GameObject automaticController; private bool useAutomaticControl; private const string automaticControlDefaultCMDLineArgument = "-automaticControl"; private void Awake() { useAutomaticControl = HasCommandLineArgument("-automaticControl"); SetControllerState(useAutomaticControl); } private void Update() { if (Input.GetKeyDown(toggleKey)) { Toggle(); } } private void Toggle() { useAutomaticControl = !useAutomaticControl; SetControllerState(useAutomaticControl); } private void SetControllerState(bool useAutomaticControl) { manualController.SetActive(!useAutomaticControl); automaticController.SetActive(useAutomaticControl); } private bool HasCommandLineArgument(string argument) { string[] commandLineArgs = Environment.GetCommandLineArgs(); string[] array = commandLineArgs; foreach (string text in array) { if (text.Equals(argument)) { return true; } } return false; } }