void checkNumberKey() { if (Input.GetKeyDown(KeyCode.Alpha1) || Input.GetKeyDown(KeyCode.Alpha2) || Input.GetKeyDown(KeyCode.Alpha3) || Input.GetKeyDown(KeyCode.Alpha4) || Input.GetKeyDown(KeyCode.Alpha5) || Input.GetKeyDown(KeyCode.Alpha6)) { string keyPreseed = Input.inputString; int keyNum = System.Convert.ToInt32(keyPreseed); // KEYNUM NO OF CARDS IN HAND if (keyNum >= 1 && keyNum <= 6) { if (allowMove[keyNum - 1]) { if (selectedObstacle != null) { Destroy(selectedObstacle.gameObject); } selectedObstacle = GameObject.Instantiate(OperatorHand[keyNum - 1], Vector3.one, OperatorHand[keyNum - 1].transform.localRotation) as Obstacles; foreach(Transform t in selectedObstacle.GetComponentsInChildren<Transform>()) { t.gameObject.layer = LayerMask.NameToLayer("IgnorePlayer"); } foreach (Collider col in selectedObstacle.GetComponentsInChildren<Collider>()) { col.enabled = false; } placingObstacle = true; currentKey = keyNum; } // code changes by Shreyas if (num_key_pressed != null) { num_key_pressed(keyNum); } //end of changes } } }