private void DetectToggleInput() { if (Input.GetKeyDown(_toggleKey)) { _commandStack.ExecuteCommand (new LightActiveToggle(_light)); } }
// Update is called once per frame void Update() { //when i press alpha 0 i need to push button down for a short amount of time and activate red material if (Input.GetKeyDown(KeyCode.Keypad0)) { if (_controllerState == ControllerState.On) { print("switch to off"); _controllerState = ControllerState.Off; } else if (_controllerState == ControllerState.Off) { print("switch to on"); _controllerState = ControllerState.On; } StartCoroutine(PushButtonDown(ButtonOnOff)); //simple toggle function } // test if something is detected by the remote command RemoteCommandIsOn(); GameObject objInControl = IsObjectInFrontOfRemote(); if (objInControl != null) { _controllerState = ControllerState.OnDetect; } else { _controllerState = ControllerState.On; } //if its on detect i can move object if (_controllerState == ControllerState.OnDetect) { if (Input.GetKeyDown(KeyCode.Keypad9)) { commandStack.ExecuteCommand(new AdvanceObjectCommand(), objInControl.GetComponent <PassiveObjectController>()); } else if (Input.GetKeyDown(KeyCode.Keypad3)) { commandStack.ExecuteCommand(new BackOffObject(), objInControl.GetComponent <PassiveObjectController>()); } } }