Ejemplo n.º 1
0
 private void Awake()
 {
     I = this;
 }
Ejemplo n.º 2
0
        private void AnchorChanged(int index)
        {
            if (currentDP == null)
            {
                return;
            }

            DPOverlayTrackedDevice device;

            bool isAnchoringToBar = false;


            switch (index)
            {
            case 0:
                device = DPOverlayTrackedDevice.RightHand;
                AnchorChanged(3);
                PurifyOverlay();
                AnchorToTheBar(false);
                break;

            case 1:
                device = DPOverlayTrackedDevice.LeftHand;
                AnchorChanged(3);
                PurifyOverlay();
                break;

            case 2:
                device = DPOverlayTrackedDevice.None;
                AnchorToTheBar(true);
                isAnchoringToBar = true;

                break;

            case 4:
                device = DPOverlayTrackedDevice.HMD;
                AnchorChanged(3);
                PurifyOverlay();
                AnchorToTheBar(false);
                break;

            default:
                device = DPOverlayTrackedDevice.None;
                ClearAnchorSettings();
                AnchorToTheBar(false);
                break;
            }

            void AnchorToTheBar(bool yes)
            {
                if (!apply)
                {
                    return;
                }

                if (yes && !currentDP.isAnchoredToTheBar)
                {
                    TheBarManager.AddAnchoredDP(currentDP);
                }
                else if (!yes && currentDP.isAnchoredToTheBar)
                {
                    TheBarManager.RemoveAnchoredDP(currentDP);
                }
            }

            void PurifyOverlay()
            {
                currentDP.ClearAllSnapData();
                CurvatureChanged(0f);
            }

            void ClearAnchorSettings()
            {
                if (smoothAnchoring.toggle.isSelected)
                {
                    smoothAnchoring.toggle.SetValue(false);
                }
                if (snapAnchoring.toggle.isSelected)
                {
                    snapAnchoring.toggle.SetValue(false);
                }
            }

            if (apply && !isAnchoringToBar)
            {
                currentDP.SetOverlayTrackedDevice(device);
            }
        }