Ejemplo n.º 1
0
        protected override void OnButtonBarGUI()
        {
            if (GUILayout.Button("Populate All", GUILayout.ExpandWidth(false)))
            {
                if (_table != null)
                {
                    RecordUndo("Populate all switch mappings");

                    var mappingConfigData = GetSwitchMappingConfig();

                    foreach (var switchId in _ids)
                    {
                        if (GetSwitchMappingEntryByID(switchId) == null)
                        {
                            var matchKey = int.TryParse(switchId, out var numericSwitchId)
                                                                ? $"sw{numericSwitchId}"
                                                                : switchId;

                            var matchedItem = _switchables.ContainsKey(matchKey)
                                                                ? _switchables[matchKey]
                                                                : null;

                            var source = GuessSource(switchId);
                            var entry  = new MappingEntryData {
                                Id            = switchId,
                                Source        = source,
                                PlayfieldItem = matchedItem == null ? string.Empty : matchedItem.Name,
                                Type          = matchedItem is KickerAuthoring || matchedItem is TriggerAuthoring || source == SwitchSource.InputSystem
                                                                        ? SwitchType.OnOff
                                                                        : SwitchType.Pulse,
                                InputActionMap = GuessInputMap(switchId),
                                InputAction    = source == SwitchSource.InputSystem ? GuessInputAction(switchId) : null,
                            };

                            mappingConfigData.MappingEntries = mappingConfigData.MappingEntries.Append(entry).ToArray();
                        }
                    }
                    Reload();
                }
            }

            if (GUILayout.Button("Remove All", GUILayout.ExpandWidth(false)))
            {
                if (_table != null)
                {
                    if (EditorUtility.DisplayDialog("Switch Manager", "Are you sure want to remove all switch mappings?", "Yes", "Cancel"))
                    {
                        RecordUndo("Remove all switch mappings");
                        var mappingConfigData = GetSwitchMappingConfig();
                        mappingConfigData.MappingEntries = new MappingEntryData[0];
                    }
                    Reload();
                }
            }
        }
Ejemplo n.º 2
0
        public SwitchListData(MappingEntryData mappingEntryData)
        {
            Id             = mappingEntryData.Id;
            Description    = mappingEntryData.Description;
            Source         = mappingEntryData.Source;
            InputActionMap = mappingEntryData.InputActionMap;
            InputAction    = mappingEntryData.InputAction;
            PlayfieldItem  = mappingEntryData.PlayfieldItem;
            Constant       = mappingEntryData.Constant;
            Type           = mappingEntryData.Type;
            Pulse          = mappingEntryData.Pulse;

            MappingEntryData = mappingEntryData;
        }