Esempio n. 1
0
        public void Update()
        {
            if (!Application.isPlaying)
            {
                return;
            }

            tetherVisualsEnabled = false;
            if (pointer.IsFocusLocked && pointer.IsTargetPositionLockedOnFocusLock && pointer.Result != null)
            {
                NearInteractionGrabbable grabbedObject = GetGrabbedObject();
                if (grabbedObject != null && grabbedObject.ShowTetherWhenManipulating)
                {
                    Vector3 graspPosition;
                    pointer.TryGetNearGraspPoint(out graspPosition);
                    tetherLine.FirstPoint = graspPosition;
                    Vector3 endPoint = pointer.Result.Details.Object.transform.TransformPoint(pointer.Result.Details.PointLocalSpace);
                    tetherLine.LastPoint = endPoint;
                    tetherVisualsEnabled = Vector3.Distance(tetherLine.FirstPoint, tetherLine.LastPoint) > minTetherLength;
                    tetherLine.enabled   = tetherVisualsEnabled;
                    tetherEndPoint.gameObject.SetActive(tetherVisualsEnabled);
                    tetherEndPoint.position = endPoint;
                }
            }

            visualsRoot.gameObject.SetActive(tetherVisualsEnabled);
        }
            public bool TryUpdateQueryBufferForLayerMask(LayerMask layerMask, Vector3 pointerPosition, QueryTriggerInteraction triggerInteraction)
            {
                grabbable    = null;
                numColliders = UnityEngine.Physics.OverlapSphereNonAlloc(
                    pointerPosition,
                    queryRadius,
                    queryBuffer,
                    layerMask,
                    triggerInteraction);

                if (numColliders == queryBuffer.Length)
                {
                    Debug.LogWarning($"Maximum number of {numColliders} colliders found in SpherePointer overlap query. Consider increasing the query buffer size in the pointer profile.");
                }

                for (int i = 0; i < numColliders; i++)
                {
                    grabbable = queryBuffer[i].GetComponent <NearInteractionGrabbable>();
                    if (grabbable != null)
                    {
                        return(true);
                    }
                }
                return(false);
            }