/// <summary> /// Create a new instance of <see cref="Axis"/> with specified negative <see cref="KeyMapping"/> and positive <see cref="KeyMapping"/>. /// </summary> /// <param name="name">Axis name.</param> /// <param name="negativeKeyMapping">Negative KeyMapping.</param> /// <param name="positiveKeyMapping">Positive KeyMapping.</param> public Axis(string name, KeyMapping negativeKeyMapping, KeyMapping positiveKeyMapping) { MName = name; Inverted = false; set(negativeKeyMapping, positiveKeyMapping); }
/// <summary> /// Creates new <see cref="Axis"/> with specified negative <see cref="KeyMapping"/> and positive <see cref="KeyMapping"/>. /// </summary> /// <returns>Created Axis.</returns> /// <param name="name">Axis name.</param> /// <param name="negative">Negative KeyMapping.</param> /// <param name="positive">Positive KeyMapping.</param> /// <param name="isTankDrive">Boolean to check if TankDrive is active.</param> public Axis SetAxis(string name, KeyMapping negative, KeyMapping positive, bool isTankDrive = false) { Axis outAxis = null; if (!isTankDrive) { if (arcadeAxesMap.TryGetValue(name, out outAxis)) { outAxis.set(negative, positive); } else { outAxis = new Axis(name, negative, positive); arcadeAxesList.Add(outAxis); arcadeAxesMap.Add(name, outAxis); } } else { if (tankAxesMap.TryGetValue(name, out outAxis)) { outAxis.set(negative, positive); } else { outAxis = new Axis(name, negative, positive); tankAxesList.Add(outAxis); tankAxesMap.Add(name, outAxis); } } return(outAxis); }
/// <summary> /// Creates new <see cref="KeyMapping"/> with specified name, primary CustomInput, and secondary CustomInput. /// </summary> /// <returns>Created KeyMapping.</returns> /// <param name="name">KeyMapping name.</param> /// <param name="primary">Primary input.</param> /// <param name="secondary">Secondary input.</param> /// <param name="isTankDrive">Boolean to check if TankDrive is active.</param> public KeyMapping SetKey(string name, CustomInput primary = null, CustomInput secondary = null, bool isTankDrive = false) { KeyMapping outKey = null; //Key to return KeyMapping defaultKey = null; //Key to store default key preferances (for resetting individual player lists) if (!isTankDrive) //Arcade Drive Enabled { if (arcadeDriveMap.TryGetValue(name, out outKey) && resetArcadeDriveMap.TryGetValue(name, out outKey)) { outKey.primaryInput = primary; outKey.secondaryInput = secondary; } else { //Sets controls to the main key list (outKey) and the default list //(defaultKey stores controls (defaults) at initialization) outKey = new KeyMapping(name, primary, secondary); defaultKey = new KeyMapping(name, primary, secondary); //Assigns each list with correct key arcadeDriveList.Add(outKey); resetArcadeDriveList.Add(defaultKey); //Assigns each key map with the correct name and key (dependent on the list) arcadeDriveMap.Add(name, outKey); resetArcadeDriveMap.Add(name, defaultKey); } } else //Tank Drive Enabled { if (tankDriveMap.TryGetValue(name, out outKey) && resetTankDriveMap.TryGetValue(name, out outKey)) { outKey.primaryInput = primary; outKey.secondaryInput = secondary; } else { //Sets controls to the main key list (outKey) and the default list //(defaultKey stores controls (defaults) at initialization) outKey = new KeyMapping(name, primary, secondary); defaultKey = new KeyMapping(name, primary, secondary); //Assigns each list with correct key tankDriveList.Add(outKey); resetTankDriveList.Add(defaultKey); //Assigns each key map with the correct name and key (dependent on the list) tankDriveMap.Add(name, outKey); resetTankDriveMap.Add(name, defaultKey); } } return(outKey); }
/// <summary> /// Set the same <see cref="CustomInput"/> as in another instance. /// </summary> /// <param name="another">Another KeyMapping instance.</param> public void set(KeyMapping another) { mPrimaryInput = another.mPrimaryInput; mSecondaryInput = another.mSecondaryInput; mThirdInput = another.mThirdInput; }
/// <summary> /// Initializes a new instance of the <see cref="KeyMapping"/> class based on another instance. /// </summary> /// <param name="another">Another KeyMapping instance.</param> public KeyMapping(KeyMapping another) { mName = another.mName; set(another); }
/// <summary> /// Set the same <see cref="CustomInput"/> as in another instance. /// </summary> /// <param name="another">Another KeyMapping instance.</param> public void set(KeyMapping another) { set(another.mName, another.mPrimaryInput, another.mSecondaryInput, another.mTertiaryInput); }
/// <summary> /// Initializes a new instance of the <see cref="KeyMapping"/> class based on another instance. /// </summary> /// <param name="another">Another KeyMapping instance.</param> public KeyMapping(KeyMapping another) { set(another); }
public Axis(string name, KeyMapping negativeKeyMapping, KeyMapping positiveKeyMapping, bool inverted = false) { set(name, negativeKeyMapping, positiveKeyMapping, inverted); }
/// <summary> /// Set negative <see cref="KeyMapping"/> and positive <see cref="KeyMapping"/>. /// </summary> /// <param name="negativeKeyMapping">Negative KeyMapping.</param> /// <param name="positiveKeyMapping">Positive KeyMapping.</param> public void set(string name, KeyMapping negativeKeyMapping, KeyMapping positiveKeyMapping, bool inverted = false) { MName = name; set(negativeKeyMapping, positiveKeyMapping, inverted); }
/// <summary> /// Set negative <see cref="KeyMapping"/> and positive <see cref="KeyMapping"/>. /// </summary> /// <param name="negativeKeyMapping">Negative KeyMapping.</param> /// <param name="positiveKeyMapping">Positive KeyMapping.</param> public void set(KeyMapping negativeKeyMapping, KeyMapping positiveKeyMapping, bool inverted = false) { Inverted = inverted; Negative = negativeKeyMapping; Positive = positiveKeyMapping; }
/// <summary> /// Set negative <see cref="KeyMapping"/> and positive <see cref="KeyMapping"/>. /// </summary> /// <param name="negativeKeyMapping">Negative KeyMapping.</param> /// <param name="positiveKeyMapping">Positive KeyMapping.</param> public void set(KeyMapping negativeKeyMapping, KeyMapping positiveKeyMapping) { Negative = negativeKeyMapping; Positive = positiveKeyMapping; }
/// <summary> /// Set the same negative <see cref="KeyMapping"/> and positive <see cref="KeyMapping"/> as in another instance. /// </summary> /// <param name="another">Another Axis instance.</param> public void set(Axis another) { mNegative = another.mNegative; mPositive = another.mPositive; Inverted = another.Inverted; }
public void AddButtonRow(string label, KeyMapping key, ref float contentHeight, ref float maxNameWidth, Action <int, Inputs.CustomInput> inputHandler, Action <int, Text> textHandler) { //======================================================================================== // Key Text vs Key Buttons //Key Text: The labels/text in the first column of the InputManager menu (see Options tab) //Key Buttons: The buttons in the second and third column of the Input Manager menu //======================================================================================== //Source: https://github.com/Gris87/InputControl #region Key text GameObject keyNameText = Instantiate(keyNamePrefab) as GameObject; keyNameText.name = label; RectTransform keyNameTextRectTransform = keyNameText.GetComponent <RectTransform>(); keyNameTextRectTransform.transform.SetParent(namesTransform); keyNameTextRectTransform.anchoredPosition3D = new Vector3(0, 0, 0); keyNameTextRectTransform.localScale = new Vector3(1, 1, 1); Text keyText = keyNameText.GetComponentInChildren <Text>(); keyText.text = label; float keyNameWidth = keyText.preferredWidth + 8; if (keyNameWidth > maxNameWidth) { maxNameWidth = keyNameWidth; } #endregion #region Key buttons GameObject keyButtons = inputHandler != null ? (Instantiate(simpleKeyButtonsPrefab) as GameObject) : (Instantiate(keyButtonsPrefab) as GameObject); keyButtons.name = label; RectTransform keyButtonsRectTransform = keyButtons.GetComponent <RectTransform>(); keyButtonsRectTransform.transform.SetParent(keysTransform); keyButtonsRectTransform.anchoredPosition3D = new Vector3(0, 0, 0); keyButtonsRectTransform.localScale = new Vector3(1, 1, 1); for (int i = 0; i < keyButtons.transform.childCount; ++i) // 3 - primary, secondary, tertiary { KeyButton buttonScript = keyButtons.transform.GetChild(i).GetComponent <KeyButton>(); if (inputHandler != null) { buttonScript.Init(label, key, i, inputHandler, textHandler); } else { buttonScript.Init(label, key, i); } buttons.Add(buttonScript); } #endregion //============================================= contentHeight += 28; }
public void AddButtonRow(string label, KeyMapping key, ref float contentHeight, ref float maxNameWidth) { AddButtonRow(label, key, ref contentHeight, ref maxNameWidth, null, null); }