示例#1
0
    public void Show()
    {
        CreateText(new JSONStorableString("", "Binds VR trackers (such as the headset or controllers) to an atom's controllers.\n\nHands have no effect when Snug is enabled, and Head has no effect when Passenger is enabled."), true);

        CreateTitle("Settings", true);
        CreateToggle(_trackers.useProfileJSON, true, "*Use Profile <i>(Not Saved In Scene)</i>", "*Use Profile <i>(Saved In Scene)</i>");
        CreateToggle(_trackers.restorePoseAfterPossessJSON, true).label = "Restore pose after possession";

        CreateSpacer(true).height = 20f;
        CreateTitle("Utilities", true);

        CreateToggle(_trackers.previewTrackerOffsetJSON, true).label = "Preview offset in 3D";

        _handsToggleJSON = new JSONStorableBool("Enable Hands", _trackers.leftHandMotionControl.enabled || _trackers.rightHandMotionControl.enabled);
        CreateToggle(_handsToggleJSON, true);
        _handsToggleJSON.setCallbackFunction = val =>
        {
            _trackers.leftHandMotionControl.enabled  = val;
            _trackers.rightHandMotionControl.enabled = val;
            if (_currentMotionControl != null && MotionControlNames.IsHands(_currentMotionControl.name))
            {
                ShowMotionControl(_currentMotionControl);
            }
        };

        if (context.trackers.viveTrackers.Any(v => v.SyncMotionControl()))
        {
            CreateSpacer(true).height = 20f;

            CreateButton("Align <i>All</i> Vive Trackers (5s timer)", true).button.onClick.AddListener(() =>
            {
                _trackerAutoSetup.AlignAll(
                    () =>
                {
                    if (_currentMotionControl == null || !MotionControlNames.IsViveTracker(_currentMotionControl.name))
                    {
                        return;
                    }
                    ShowMotionControl(_currentMotionControl);
                    context.Refresh();
                    context.embody.activeJSON.val = true;
                });
            });
        }

        _motionControlJSON = _motionControlJSON ?? new JSONStorableStringChooser(
            "",
            new List <string>(),
            _trackers.motionControls[0].name ?? _none,
            "Tracker",
            (val) => ShowMotionControl(_trackers.motionControls.FirstOrDefault(mc => mc.name == val))
            );
        CreateScrollablePopup(_motionControlJSON);
        _motionControlJSON.choices = _trackers.motionControls
                                     .Where(mc => mc.SyncMotionControl() || MotionControlNames.IsHeadOrHands(mc.name))
                                     .Select(mc => mc.name)
                                     .ToList();

        ShowMotionControl(_trackers.motionControls.FirstOrDefault(mc => mc.name == _motionControlJSON.val));
    }