Пример #1
0
        internal override void AddToPanel(uGUI_TabbedControlsPanel panel, int tabIndex)
        {
            // Add item
            OptionGameObject = panel.AddItem(tabIndex, panel.bindingOptionPrefab);

            // Update text
            Text text = OptionGameObject.GetComponentInChildren <Text>();

            if (text != null)
            {
                OptionGameObject.GetComponentInChildren <TranslationLiveUpdate>().translationKey = Label;
                text.text = Language.main.Get(Label);
            }

            // Create bindings
            uGUI_Bindings bindings = OptionGameObject.GetComponentInChildren <uGUI_Bindings>();
            uGUI_Binding  binding  = bindings.bindings[0];

            // Destroy secondary bindings
            int last = bindings.bindings.Length - 1;

            UnityEngine.Object.Destroy(bindings.bindings[last].gameObject);
            UnityEngine.Object.Destroy(bindings);

            // Update bindings
            binding.device = Device;
            binding.value  = KeyCodeUtils.KeyCodeToString(Key);
            binding.onValueChanged.RemoveAllListeners();
            var callback = new UnityAction <KeyCode>((KeyCode key) => parentOptions.OnKeybindChange(Id, key));

            binding.onValueChanged.AddListener(new UnityAction <string>((string s) => callback?.Invoke(KeyCodeUtils.StringToKeyCode(s))));

            base.AddToPanel(panel, tabIndex);
        }
Пример #2
0
        internal override void AddToPanel(uGUI_TabbedControlsPanel panel, int tabIndex)
        {
            // Add button to GUI
            Button componentInChildren = panel.AddItem(tabIndex, panel.buttonPrefab, Label).GetComponentInChildren <Button>();

            // Store a reference to parent object to simplify further modifications
            OptionGameObject = componentInChildren.transform.parent.gameObject;

            // Setup "on click" event
            componentInChildren.onClick.AddListener(new UnityAction(() =>
            {
                // Apply "deselected" style to button right after it is clicked
                componentInChildren.OnDeselect(null);
                // Propagate button click event to parent
                parentOptions.OnButtonClicked(Id);
            }));

            // Add button to panel
            base.AddToPanel(panel, tabIndex);
        }
Пример #3
0
        internal override void AddToPanel(uGUI_TabbedControlsPanel panel, int tabIndex)
        {
            // Add item
            OptionGameObject = panel.AddItem(tabIndex, panel.bindingOptionPrefab);

            // Update text
            Text text = OptionGameObject.GetComponentInChildren <Text>();

            if (text != null)
            {
                OptionGameObject.GetComponentInChildren <TranslationLiveUpdate>().translationKey = Label;
                text.text = Language.main.Get(Label);
            }

            // Create bindings
            uGUI_Bindings bindings = OptionGameObject.GetComponentInChildren <uGUI_Bindings>();
            uGUI_Binding  binding  = bindings.bindings[0];

            // Destroy secondary bindings
            int last = bindings.bindings.Length - 1;

            UnityEngine.Object.Destroy(bindings.bindings[last].gameObject);
            UnityEngine.Object.Destroy(bindings);

            // Update bindings
            binding.device = Device;
            binding.value  = KeyCodeUtils.KeyCodeToString(Key);
#if SUBNAUTICA
            binding.onValueChanged.RemoveAllListeners();
            var callback = new UnityAction <KeyCode>((KeyCode key) => parentOptions.OnKeybindChange(Id, key));
            binding.onValueChanged.AddListener(new UnityAction <string>((string s) => callback?.Invoke(KeyCodeUtils.StringToKeyCode(s))));
#elif BELOWZERO
            binding.action     = ButtonPatcher.EnsureButton(Label, KeyCodeUtils.KeyCodeToString(Key), Device);
            binding.bindingSet = GameInput.BindingSet.Primary;
            var callback = new UnityAction <KeyCode>((KeyCode key) => parentOptions.OnKeybindChange(Id, key));
            binding.bindCallback = new Action <GameInput.Device, GameInput.Button, GameInput.BindingSet, string>((GameInput.Device device, GameInput.Button button, GameInput.BindingSet bindingSet, string s) => { callback?.Invoke(KeyCodeUtils.StringToKeyCode(s)); panel.TryBind1_0(device, button, bindingSet, s); binding.RefreshValue(); });
#endif

            base.AddToPanel(panel, tabIndex);
        }