public static GameObject CreateInputWindow(string newKeyName) { Canvas canvas = CreateCanvas(null, "Input assign", 20, false); InputAssign assign = canvas.gameObject.AddComponent <InputAssign>(); //assign.keyName = newKeyName; InputListener listener = canvas.gameObject.AddComponent <InputListener>(); listener.StartListening(true, true); listener.OnInputRecived.AddListener(assign.Assign); //back color Image backColor = CreateImageObject(canvas.transform, Color.black, "Color"); HorizontalLayoutGroup backColorGroup = backColor.gameObject.AddComponent <HorizontalLayoutGroup>(); backColorGroup.padding = new RectOffset(5, 5, 5, 5); backColorGroup.childForceExpandHeight = false; backColorGroup.childForceExpandWidth = false; backColorGroup.childAlignment = TextAnchor.MiddleCenter; ContentSizeFitter backColorContentFit = backColor.gameObject.AddComponent <ContentSizeFitter>(); backColorContentFit.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; backColorContentFit.verticalFit = ContentSizeFitter.FitMode.PreferredSize; //text TextMeshProUGUI text = CreateTextObject(backColor.transform); text.text = "Assign the new key"; text.color = new Color(1f, 1f, 1f); ContentSizeFitter textContentFit = text.gameObject.AddComponent <ContentSizeFitter>(); textContentFit.horizontalFit = ContentSizeFitter.FitMode.PreferredSize; textContentFit.verticalFit = ContentSizeFitter.FitMode.PreferredSize; text.transform.position = new Vector2(0f, 0f); return(canvas.gameObject); }
public void UpdateDropdown() { if (playerA.value == 0 && playerB.value == 0) { //Movimento e interazione InputAssign.UpdateDictionaryMovement("PlayerAHorizontal", "Horizontal"); InputAssign.UpdateDictionaryMovement("PlayerAVertical", "Vertical"); InputAssign.UpdateDictionaryMovement("PlayerBHorizontal", "HorizontalB"); InputAssign.UpdateDictionaryMovement("PlayerBVertical", "VerticalB"); //Interazione InputAssign.UpdateDictionaryInteract("PlayerAInteract", KeyCode.E); InputAssign.UpdateDictionaryInteract("PlayerBInteract", KeyCode.Return); //salto InputAssign.UpdateDictionaryInteract("PlayerAJump", KeyCode.Space); InputAssign.UpdateDictionaryInteract("PlayerBJump", KeyCode.RightControl); //Inventario InputAssign.UpdateDictionaryInteract("PlayerAInventario", KeyCode.Tab); InputAssign.UpdateDictionaryInteract("PlayerBInventario", KeyCode.RightShift); //Stringhe per i tasti InputAssign.UpdateDictionaryInteractString("PlayerAInteract", "E"); InputAssign.UpdateDictionaryInteractString("PlayerBInteract", "Invio"); descrizioneControlliA.text = "Movimento: WASD\nSalto: Spazio\nInterazione: E\nInventario: Tab"; descrizioneControlliB.text = "Movimento: Frecce\nSalto: Ctrl Dx\nInterazione: Invio\nInventario: Shift Dx"; } else if (playerA.value == 1 && playerB.value == 1) { InputAssign.UpdateDictionaryMovement("PlayerAHorizontal", "HorizontalJoystick"); InputAssign.UpdateDictionaryMovement("PlayerAVertical", "VerticalJoystick"); InputAssign.UpdateDictionaryInteract("PlayerAInteract", KeyCode.Joystick1Button0); InputAssign.UpdateDictionaryMovement("PlayerBHorizontal", "HorizontalJoystick1"); InputAssign.UpdateDictionaryMovement("PlayerBVertical", "VerticalJoystick1"); InputAssign.UpdateDictionaryInteract("PlayerBInteract", KeyCode.Joystick2Button0); //salto InputAssign.UpdateDictionaryInteract("PlayerAJump", KeyCode.Joystick1Button1); InputAssign.UpdateDictionaryInteract("PlayerBJump", KeyCode.Joystick2Button1); //Inventario InputAssign.UpdateDictionaryInteract("PlayerAInventario", KeyCode.Joystick1Button2); InputAssign.UpdateDictionaryInteract("PlayerBInventario", KeyCode.Joystick2Button2); InputAssign.UpdateDictionaryInteractString("PlayerAInteract", "Triangolo"); InputAssign.UpdateDictionaryInteractString("PlayerBInteract", "Triangolo"); descrizioneControlliA.text = "Movimento: Analogico\nSalto: O\nInterazione: Triangolo\nInventario: X"; descrizioneControlliB.text = "Movimento: Analogico\nSalto: O\nInterazione: Triangolo\nInventario: X"; } else if (playerA.value == 0 && playerB.value == 1) { InputAssign.UpdateDictionaryMovement("PlayerAHorizontal", "Horizontal"); InputAssign.UpdateDictionaryMovement("PlayerAVertical", "Vertical"); InputAssign.UpdateDictionaryInteract("PlayerAInteract", KeyCode.E); InputAssign.UpdateDictionaryMovement("PlayerBHorizontal", "HorizontalJoystick"); InputAssign.UpdateDictionaryMovement("PlayerBVertical", "VerticalJoystick"); InputAssign.UpdateDictionaryInteract("PlayerBInteract", KeyCode.Joystick1Button0); //salto InputAssign.UpdateDictionaryInteract("PlayerAJump", KeyCode.Space); InputAssign.UpdateDictionaryInteract("PlayerBJump", KeyCode.Joystick1Button1); InputAssign.UpdateDictionaryInteract("PlayerAInventario", KeyCode.Tab); InputAssign.UpdateDictionaryInteract("PlayerBInventario", KeyCode.Joystick1Button2); InputAssign.UpdateDictionaryInteractString("PlayerAInteract", "E"); InputAssign.UpdateDictionaryInteractString("PlayerBInteract", "Triangolo"); descrizioneControlliA.text = "Movimento: WASD\nSalto: Spazio\nInterazione: E\nInventario: Tab"; descrizioneControlliB.text = "Movimento: Analogico\nSalto: O\nInterazione: Triangolo\nInventario: X"; } else if (playerA.value == 1 && playerB.value == 0) { InputAssign.UpdateDictionaryMovement("PlayerAHorizontal", "HorizontalJoystick"); InputAssign.UpdateDictionaryMovement("PlayerAVertical", "VerticalJoystick"); InputAssign.UpdateDictionaryInteract("PlayerAInteract", KeyCode.Joystick1Button0); InputAssign.UpdateDictionaryMovement("PlayerBHorizontal", "HorizontalB"); InputAssign.UpdateDictionaryMovement("PlayerBVertical", "VerticalB"); InputAssign.UpdateDictionaryInteract("PlayerBInteract", KeyCode.Return); InputAssign.UpdateDictionaryInteract("PlayerAInventario", KeyCode.Joystick1Button2); InputAssign.UpdateDictionaryInteract("PlayerBInventario", KeyCode.RightShift); //salto InputAssign.UpdateDictionaryInteract("PlayerAJump", KeyCode.Joystick1Button1); InputAssign.UpdateDictionaryInteract("PlayerBJump", KeyCode.RightControl); InputAssign.UpdateDictionaryInteractString("PlayerAInteract", "Triangolo"); InputAssign.UpdateDictionaryInteractString("PlayerBInteract", "Invio"); descrizioneControlliA.text = "Movimento: Analogico\nSalto: O\nInterazione: Triangolo\nInventario: X"; descrizioneControlliB.text = "Movimento: Frecce\nSalto: Ctrl Dx\nInterazione: Invio\nInventario: Shift Dx"; } }