示例#1
0
        void OnObjectsDropped(Transform rayOrigin, Transform[] grabbedObjects)
        {
            HashSet <Transform> objects;

            if (!m_GrabbedObjects.TryGetValue(rayOrigin, out objects))
            {
                return;
            }

            var eventObjects = new List <Transform>();

            foreach (var grabbedObject in grabbedObjects)
            {
                // Avoid exceptions for destroyed objects
                if (grabbedObject == null)
                {
                    continue;
                }

                objects.Remove(grabbedObject);

                if (m_ViewerModule != null)
                {
                    // Dropping the player head updates the camera rig position
                    if (grabbedObject.CompareTag(EditorXR.VRPlayerTag))
                    {
                        m_ViewerModule.DropPlayerHead(grabbedObject);
                    }
                    else if (m_SceneObjectModule != null && this.IsOverShoulder(rayOrigin) && (m_MiniWorldModule == null || !m_MiniWorldModule.rays.ContainsKey(rayOrigin)))
                    {
                        m_SceneObjectModule.DeleteSceneObject(grabbedObject.gameObject);
                    }
                    else
                    {
                        eventObjects.Add(grabbedObject);
                    }
                }
            }

            if (objects.Count == 0)
            {
                m_GrabbedObjects.Remove(rayOrigin);
            }

            if (objectsDropped != null)
            {
                objectsDropped(rayOrigin, eventObjects.ToArray());
            }
        }