Exemple #1
0
            internal void UpdateDirectSelection()
            {
                m_DirectSelections.Clear();
                m_ActiveStates.Clear();

                var directSelection = objectsGrabber;
                var evrRays         = evr.m_Rays;

                evrRays.ForEachProxyDevice((deviceData) =>
                {
                    var rayOrigin = deviceData.rayOrigin;
                    var input     = deviceData.directSelectInput;
                    var obj       = GetDirectSelectionForRayOrigin(rayOrigin, input);
                    if (obj && !obj.CompareTag(k_VRPlayerTag))
                    {
                        m_ActiveStates.Add(input);
                        m_DirectSelections[rayOrigin] = new DirectSelectionData
                        {
                            gameObject = obj,
                            node       = deviceData.node,
                            input      = input
                        };
                    }
                    else if (directSelection != null && directSelection.GetHeldObjects(rayOrigin) != null)
                    {
                        m_ActiveStates.Add(input);
                    }
                });

                foreach (var ray in evr.m_MiniWorlds.rays)
                {
                    var rayOrigin    = ray.Key;
                    var miniWorldRay = ray.Value;
                    var input        = miniWorldRay.directSelectInput;
                    var go           = GetDirectSelectionForRayOrigin(rayOrigin, input);
                    if (go != null)
                    {
                        m_ActiveStates.Add(input);
                        m_DirectSelections[rayOrigin] = new DirectSelectionData
                        {
                            gameObject = go,
                            node       = ray.Value.node,
                            input      = input
                        };
                    }
                    else if (miniWorldRay.dragObjects != null ||
                             (directSelection != null && directSelection.GetHeldObjects(rayOrigin) != null))
                    {
                        m_ActiveStates.Add(input);
                    }
                }

                // Only activate direct selection input if the cone is inside of an object, so a trigger press can be detected,
                // and keep it active if we are dragging
                evrRays.ForEachProxyDevice((deviceData) =>
                {
                    var input    = deviceData.directSelectInput;
                    input.active = m_ActiveStates.Contains(input);
                });
            }
        Dictionary <Transform, DirectSelectionData> GetDirectSelection()
        {
            m_DirectSelectionResults.Clear();
            m_ActiveStates.Clear();

            var directSelection = m_ObjectsGrabber;

            ForEachRayOrigin((proxy, rayOriginPair, device, deviceData) =>
            {
                var rayOrigin = rayOriginPair.Value;
                var input     = deviceData.directSelectInput;
                var obj       = GetDirectSelectionForRayOrigin(rayOrigin, input);
                if (obj && !obj.CompareTag(kVRPlayerTag))
                {
                    m_ActiveStates.Add(input);
                    m_DirectSelectionResults[rayOrigin] = new DirectSelectionData
                    {
                        gameObject = obj,
                        node       = rayOriginPair.Key,
                        input      = input
                    };
                }
                else if (directSelection != null && directSelection.GetHeldObjects(rayOrigin) != null)
                {
                    m_ActiveStates.Add(input);
                }
            });

            foreach (var ray in m_MiniWorldRays)
            {
                var rayOrigin    = ray.Key;
                var miniWorldRay = ray.Value;
                var input        = miniWorldRay.directSelectInput;
                var go           = GetDirectSelectionForRayOrigin(rayOrigin, input);
                if (go != null)
                {
                    m_ActiveStates.Add(input);
                    m_DirectSelectionResults[rayOrigin] = new DirectSelectionData
                    {
                        gameObject = go,
                        node       = ray.Value.node,
                        input      = input
                    };
                }
                else if (miniWorldRay.dragObjects != null ||
                         (directSelection != null && directSelection.GetHeldObjects(rayOrigin) != null))
                {
                    m_ActiveStates.Add(input);
                }
            }

            // Only activate direct selection input if the cone is inside of an object, so a trigger press can be detected,
            // and keep it active if we are dragging
            ForEachRayOrigin((proxy, pair, device, deviceData) =>
            {
                var input    = deviceData.directSelectInput;
                input.active = m_ActiveStates.Contains(input);
            });

            return(m_DirectSelectionResults);
        }