public InputSourceEditor(BaseInputCollector inputCollector, int inputSourceIndex) { this.inputCollectorInstanceID = inputCollector.GetInstanceID(); this.inputSourceIndex = inputSourceIndex; this.baseInputSource = inputCollector[inputSourceIndex]; this.Show(); }
protected void Start() { if (InputCollectorManager.Instance != null) { InputCollector = InputCollectorManager.Instance.GetInputCollector(_playerID); _currentinputSource = ConvertToInputSourceDefinition(InputCollector.CurrentInputSourceInstance); InputCollector.InputSourceChanged -= InputSourceChanged; InputCollector.InputSourceChanged += InputSourceChanged; } }
public void AddInputCollector(GameObject inputCollectorPrefab, int playerID = -1) { BaseInputCollector inputCollector = Instantiate(inputCollectorPrefab, this.transform, false).GetComponent <BaseInputCollector>(); inputCollector.transform.position = Vector3.zero; inputCollector.transform.rotation = Quaternion.identity; inputCollector.transform.localScale = Vector3.zero; inputCollector.PlayerNumber = playerID > -1 ? playerID : _inputCollectorsDictionary.Count; inputCollector.gameObject.name = string.Format("Player {0}", inputCollector.PlayerNumber); _inputCollectors.Add(inputCollector); _inputCollectorsDictionary.Add(inputCollector.PlayerNumber, inputCollector); }
/// <summary> /// Returns InputCollector by it's PlayerNumber. /// If there are only one InputCollector instance method will return that one. /// </summary> /// <param name="playerNumber">PlayerNumber</param> /// <returns>InputCollector instance.</returns> public BaseInputCollector GetInputCollector(int playerNumber = 0) { BaseInputCollector _inputCollector = null; if (_inputCollectorsDictionary.Count == 1) { _inputCollectorsDictionary.TryGetValue(0, out _inputCollector); } else { _inputCollectorsDictionary.TryGetValue(playerNumber, out _inputCollector); } return(_inputCollector); }
private void OnEnable() { inputCollector = target as BaseInputCollector; list = new ReorderableList( serializedObject, serializedObject.FindProperty("inputSources"), true, true, true, true); list.drawHeaderCallback = DrawHeader; list.drawElementCallback = DrawListElement; list.onAddCallback = AddElement; list.onRemoveCallback = RemoveElement; _inputSourcesTypes = InputCollectorManager.GetDerivedTypes <BaseInputSource>(); _inputSourcesMenu = GenerateMenuFormTypes(_inputSourcesTypes, AddNewSource); }