コード例 #1
0
        public void maybeReparentCrosshair()
        {
            if (SceneManager.GetActiveScene().name != "main" || guiCanvas == null || !ensureCrosshairCanvas() || !ensureCrosshairCamera())
            {
                return;
            }
            if ((_canvasCrosshairRoot == null || _canvasCrosshairRootClone == null) &&
                !findVanillaCrosshairs(guiCanvas.transform))
            {
                return;
            }
            reparentPieceHealthObjects();
            if (VHVRConfig.UseVrControls())
            {
                reparentAndCloneHoverNameObjects();
            }
            _canvasCrosshairRoot.SetActive(false); // Disable the original crosshairs
            _canvasCrosshairRootClone.SetActive(VRPlayer.attachedToPlayer);
            _canvasCrosshairRootClone.transform.SetParent(_crosshairCanvas.transform, false);
            _crosshairClone.SetActive(VHVRConfig.ShowStaticCrosshair());
            if (crosshairCloneLeftHand)
            {
                crosshairCloneLeftHand.SetActive(VHVRConfig.ShowStaticCrosshair());
            }
            var rectTransform = _canvasCrosshairRootClone.GetComponent <RectTransform>();

            setCrosshairCanvasPositionAndScale();
            setPieceHealthCanvasPositionAndScale();
            if (VHVRConfig.UseVrControls())
            {
                setHoverNameCanvasesPositionAndScale();
            }
            UpdateHudReferences();
            if (rectTransform == null)
            {
                LogError("Crosshair Rect Transform is Null");
                return;
            }
            rectTransform.SetParent(_crosshairCanvas.GetComponent <RectTransform>());
        }