RaySnap() public static method

Casts ray against the scene and report if an object lies in its path.

public static RaySnap ( Ray ray ) : object
ray UnityEngine.Ray
return object
        public void OnSceneDrag(SceneView sceneView)
        {
            GameObject go = target as GameObject;

            if (!PrefabUtility.IsPartOfPrefabAsset(go))
            {
                return;
            }

            var prefabAssetRoot = go.transform.root.gameObject;

            Event evt = Event.current;

            switch (evt.type)
            {
            case EventType.DragUpdated:

                Scene destinationScene = sceneView.customScene.IsValid() ? sceneView.customScene : SceneManager.GetActiveScene();
                if (dragObject == null)
                {
                    dragObject           = (GameObject)PrefabUtility.InstantiatePrefab(prefabAssetRoot, destinationScene);
                    dragObject.hideFlags = HideFlags.HideInHierarchy;
                    dragObject.name      = go.name;
                }

                if (HandleUtility.ignoreRaySnapObjects == null)
                {
                    HandleUtility.ignoreRaySnapObjects = dragObject.GetComponentsInChildren <Transform>();
                }

                DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                object hit = HandleUtility.RaySnap(HandleUtility.GUIPointToWorldRay(evt.mousePosition));

                if (hit != null)
                {
                    RaycastHit rh     = (RaycastHit)hit;
                    float      offset = 0;
                    if (Tools.pivotMode == PivotMode.Center)
                    {
                        float geomOffset = HandleUtility.CalcRayPlaceOffset(HandleUtility.ignoreRaySnapObjects, rh.normal);
                        if (geomOffset != Mathf.Infinity)
                        {
                            offset = Vector3.Dot(dragObject.transform.position, rh.normal) - geomOffset;
                        }
                    }
                    dragObject.transform.position = Matrix4x4.identity.MultiplyPoint(rh.point + (rh.normal * offset));
                }
                else
                {
                    dragObject.transform.position = HandleUtility.GUIPointToWorldRay(evt.mousePosition).GetPoint(10);
                }

                // Use prefabs original z position when in 2D mode
                if (sceneView.in2DMode)
                {
                    Vector3 dragPosition = dragObject.transform.position;
                    dragPosition.z = prefabAssetRoot.transform.position.z;
                    dragObject.transform.position = dragPosition;
                }

                evt.Use();
                break;

            case EventType.DragPerform:

                var stage = StageNavigationManager.instance.currentItem;
                if (stage.isPrefabStage)
                {
                    var prefabAssetThatIsAddedTo = AssetDatabase.LoadMainAssetAtPath(stage.prefabAssetPath);
                    if (PrefabUtility.CheckIfAddingPrefabWouldResultInCyclicNesting(prefabAssetThatIsAddedTo, go))
                    {
                        PrefabUtility.ShowCyclicNestingWarningDialog();
                        return;
                    }
                }

                Transform parent = sceneView.customParentForDraggedObjects;

                string uniqueName = GameObjectUtility.GetUniqueNameForSibling(parent, dragObject.name);
                if (parent != null)
                {
                    dragObject.transform.parent = parent;
                }
                dragObject.hideFlags = 0;
                Undo.RegisterCreatedObjectUndo(dragObject, "Place " + dragObject.name);
                EditorUtility.SetDirty(dragObject);
                DragAndDrop.AcceptDrag();
                Selection.activeObject             = dragObject;
                HandleUtility.ignoreRaySnapObjects = null;
                if (SceneView.mouseOverWindow != null)
                {
                    SceneView.mouseOverWindow.Focus();
                }
                dragObject.name = uniqueName;
                dragObject      = null;
                evt.Use();
                break;

            case EventType.DragExited:
                if (dragObject)
                {
                    UnityObject.DestroyImmediate(dragObject, false);
                    HandleUtility.ignoreRaySnapObjects = null;
                    dragObject = null;
                    evt.Use();
                }
                break;
            }
        }
Example #2
0
        public void OnSceneDrag(SceneView sceneView)
        {
            GameObject gameObject = base.target as GameObject;
            PrefabType prefabType = PrefabUtility.GetPrefabType(gameObject);

            if (prefabType == PrefabType.Prefab || prefabType == PrefabType.ModelPrefab)
            {
                Event     current = Event.current;
                EventType type    = current.type;
                if (type != EventType.DragUpdated)
                {
                    if (type != EventType.DragPerform)
                    {
                        if (type == EventType.DragExited)
                        {
                            if (GameObjectInspector.dragObject)
                            {
                                UnityEngine.Object.DestroyImmediate(GameObjectInspector.dragObject, false);
                                HandleUtility.ignoreRaySnapObjects = null;
                                GameObjectInspector.dragObject     = null;
                                current.Use();
                            }
                        }
                    }
                    else
                    {
                        string uniqueNameForSibling = GameObjectUtility.GetUniqueNameForSibling(null, GameObjectInspector.dragObject.name);
                        GameObjectInspector.dragObject.hideFlags = HideFlags.None;
                        Undo.RegisterCreatedObjectUndo(GameObjectInspector.dragObject, "Place " + GameObjectInspector.dragObject.name);
                        EditorUtility.SetDirty(GameObjectInspector.dragObject);
                        DragAndDrop.AcceptDrag();
                        Selection.activeObject             = GameObjectInspector.dragObject;
                        HandleUtility.ignoreRaySnapObjects = null;
                        EditorWindow.mouseOverWindow.Focus();
                        GameObjectInspector.dragObject.name = uniqueNameForSibling;
                        GameObjectInspector.dragObject      = null;
                        current.Use();
                    }
                }
                else
                {
                    if (GameObjectInspector.dragObject == null)
                    {
                        GameObjectInspector.dragObject           = (GameObject)PrefabUtility.InstantiatePrefab(PrefabUtility.FindPrefabRoot(gameObject));
                        GameObjectInspector.dragObject.hideFlags = HideFlags.HideInHierarchy;
                        GameObjectInspector.dragObject.name      = gameObject.name;
                    }
                    if (HandleUtility.ignoreRaySnapObjects == null)
                    {
                        HandleUtility.ignoreRaySnapObjects = GameObjectInspector.dragObject.GetComponentsInChildren <Transform>();
                    }
                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                    object obj = HandleUtility.RaySnap(HandleUtility.GUIPointToWorldRay(current.mousePosition));
                    if (obj != null)
                    {
                        RaycastHit raycastHit = (RaycastHit)obj;
                        float      d          = 0f;
                        if (Tools.pivotMode == PivotMode.Center)
                        {
                            float num = HandleUtility.CalcRayPlaceOffset(HandleUtility.ignoreRaySnapObjects, raycastHit.normal);
                            if (num != float.PositiveInfinity)
                            {
                                d = Vector3.Dot(GameObjectInspector.dragObject.transform.position, raycastHit.normal) - num;
                            }
                        }
                        GameObjectInspector.dragObject.transform.position = Matrix4x4.identity.MultiplyPoint(raycastHit.point + raycastHit.normal * d);
                    }
                    else
                    {
                        GameObjectInspector.dragObject.transform.position = HandleUtility.GUIPointToWorldRay(current.mousePosition).GetPoint(10f);
                    }
                    if (sceneView.in2DMode)
                    {
                        Vector3 position = GameObjectInspector.dragObject.transform.position;
                        position.z = PrefabUtility.FindPrefabRoot(gameObject).transform.position.z;
                        GameObjectInspector.dragObject.transform.position = position;
                    }
                    current.Use();
                }
            }
        }
        public void OnSceneDrag(SceneView sceneView)
        {
            GameObject go         = target as GameObject;
            PrefabType prefabType = PrefabUtility.GetPrefabType(go);

            if (prefabType != PrefabType.Prefab && prefabType != PrefabType.ModelPrefab)
            {
                return;
            }

            Event evt = Event.current;

            switch (evt.type)
            {
            case EventType.DragUpdated:
                if (dragObject == null)
                {
                    dragObject           = (GameObject)PrefabUtility.InstantiatePrefab(PrefabUtility.FindPrefabRoot(go));
                    dragObject.hideFlags = HideFlags.HideInHierarchy;
                    dragObject.name      = go.name;
                }

                if (HandleUtility.ignoreRaySnapObjects == null)
                {
                    HandleUtility.ignoreRaySnapObjects = dragObject.GetComponentsInChildren <Transform>();
                }

                DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                object hit = HandleUtility.RaySnap(HandleUtility.GUIPointToWorldRay(evt.mousePosition));
                if (hit != null)
                {
                    RaycastHit rh     = (RaycastHit)hit;
                    float      offset = 0;
                    if (Tools.pivotMode == PivotMode.Center)
                    {
                        float geomOffset = HandleUtility.CalcRayPlaceOffset(HandleUtility.ignoreRaySnapObjects, rh.normal);
                        if (geomOffset != Mathf.Infinity)
                        {
                            offset = Vector3.Dot(dragObject.transform.position, rh.normal) - geomOffset;
                        }
                    }
                    dragObject.transform.position = Matrix4x4.identity.MultiplyPoint(rh.point + (rh.normal * offset));
                }
                else
                {
                    dragObject.transform.position = HandleUtility.GUIPointToWorldRay(evt.mousePosition).GetPoint(10);
                }

                // Use prefabs original z position when in 2D mode
                if (sceneView.in2DMode)
                {
                    Vector3 dragPosition = dragObject.transform.position;
                    dragPosition.z = PrefabUtility.FindPrefabRoot(go).transform.position.z;
                    dragObject.transform.position = dragPosition;
                }

                evt.Use();
                break;

            case EventType.DragPerform:
                string uniqueName = GameObjectUtility.GetUniqueNameForSibling(null, dragObject.name);
                dragObject.hideFlags = 0;
                Undo.RegisterCreatedObjectUndo(dragObject, "Place " + dragObject.name);
                EditorUtility.SetDirty(dragObject);
                DragAndDrop.AcceptDrag();
                Selection.activeObject             = dragObject;
                HandleUtility.ignoreRaySnapObjects = null;
                if (SceneView.mouseOverWindow != null)
                {
                    SceneView.mouseOverWindow.Focus();
                }
                dragObject.name = uniqueName;
                dragObject      = null;
                evt.Use();
                break;

            case EventType.DragExited:
                if (dragObject)
                {
                    UnityObject.DestroyImmediate(dragObject, false);
                    HandleUtility.ignoreRaySnapObjects = null;
                    dragObject = null;
                    evt.Use();
                }
                break;
            }
        }
        public void OnSceneDrag(SceneView sceneView)
        {
            GameObject target = this.target as GameObject;

            switch (PrefabUtility.GetPrefabType(target))
            {
            case PrefabType.Prefab:
            case PrefabType.ModelPrefab:
            {
                Event     current = Event.current;
                EventType type    = current.type;
                if (type != EventType.DragUpdated)
                {
                    if (type == EventType.DragPerform)
                    {
                        string uniqueNameForSibling = GameObjectUtility.GetUniqueNameForSibling(null, dragObject.name);
                        dragObject.hideFlags = HideFlags.None;
                        Undo.RegisterCreatedObjectUndo(dragObject, "Place " + dragObject.name);
                        EditorUtility.SetDirty(dragObject);
                        DragAndDrop.AcceptDrag();
                        Selection.activeObject             = dragObject;
                        HandleUtility.ignoreRaySnapObjects = null;
                        EditorWindow.mouseOverWindow.Focus();
                        dragObject.name = uniqueNameForSibling;
                        dragObject      = null;
                        current.Use();
                        return;
                    }
                    if ((type == EventType.DragExited) && (dragObject != null))
                    {
                        UnityEngine.Object.DestroyImmediate(dragObject, false);
                        HandleUtility.ignoreRaySnapObjects = null;
                        dragObject = null;
                        current.Use();
                    }
                }
                else
                {
                    if (dragObject == null)
                    {
                        dragObject = (GameObject)PrefabUtility.InstantiatePrefab(PrefabUtility.FindPrefabRoot(target));
                        HandleUtility.ignoreRaySnapObjects = dragObject.GetComponentsInChildren <Transform>();
                        dragObject.hideFlags = HideFlags.HideInHierarchy;
                        dragObject.name      = target.name;
                    }
                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                    object obj3 = HandleUtility.RaySnap(HandleUtility.GUIPointToWorldRay(current.mousePosition));
                    if (obj3 != null)
                    {
                        RaycastHit hit = (RaycastHit)obj3;
                        float      num = 0f;
                        if (Tools.pivotMode == PivotMode.Center)
                        {
                            float num2 = HandleUtility.CalcRayPlaceOffset(HandleUtility.ignoreRaySnapObjects, hit.normal);
                            if (num2 != float.PositiveInfinity)
                            {
                                num = Vector3.Dot(dragObject.transform.position, hit.normal) - num2;
                            }
                        }
                        dragObject.transform.position = Matrix4x4.identity.MultiplyPoint(hit.point + ((Vector3)(hit.normal * num)));
                    }
                    else
                    {
                        dragObject.transform.position = HandleUtility.GUIPointToWorldRay(current.mousePosition).GetPoint(10f);
                    }
                    if (sceneView.in2DMode)
                    {
                        Vector3 position = dragObject.transform.position;
                        position.z = PrefabUtility.FindPrefabRoot(target).transform.position.z;
                        dragObject.transform.position = position;
                    }
                    current.Use();
                }
                break;
            }
            }
        }
Example #5
0
        public static void OnSceneDrag(SceneView sceneView)
        {
            Event current = Event.current;

            if (current.type != EventType.DragUpdated && current.type != EventType.DragPerform && current.type != EventType.DragExited)
            {
                return;
            }
            if (!sceneView.in2DMode)
            {
                GameObject gameObject = HandleUtility.PickGameObject(Event.current.mousePosition, true);
                if (gameObject != null && DragAndDrop.objectReferences.Length == 1 && DragAndDrop.objectReferences[0] as Texture != null && gameObject.GetComponent <Renderer>() != null)
                {
                    SpriteUtility.CleanUp(true);
                    return;
                }
            }
            EventType type = current.type;

            if (type != EventType.DragUpdated)
            {
                if (type != EventType.DragPerform)
                {
                    if (type == EventType.DragExited)
                    {
                        if (SpriteUtility.s_SceneDragObjects != null && SpriteUtility.s_SceneDragObjects != null)
                        {
                            SpriteUtility.CleanUp(true);
                            current.Use();
                        }
                    }
                }
                else
                {
                    Sprite[] spriteFromDraggedPathsOrObjects = SpriteUtility.GetSpriteFromDraggedPathsOrObjects();
                    if (spriteFromDraggedPathsOrObjects != null && SpriteUtility.s_SceneDragObjects != null)
                    {
                        if (SpriteUtility.s_DragType == SpriteUtility.DragType.SpriteAnimation)
                        {
                            SpriteUtility.AddAnimationToGO((GameObject)SpriteUtility.s_SceneDragObjects[0], spriteFromDraggedPathsOrObjects);
                        }
                        using (List <UnityEngine.Object> .Enumerator enumerator = SpriteUtility.s_SceneDragObjects.GetEnumerator())
                        {
                            while (enumerator.MoveNext())
                            {
                                GameObject gameObject2 = (GameObject)enumerator.Current;
                                Undo.RegisterCreatedObjectUndo(gameObject2, "Create Sprite");
                                gameObject2.hideFlags = HideFlags.None;
                            }
                        }
                        Selection.objects = SpriteUtility.s_SceneDragObjects.ToArray();
                        SpriteUtility.CleanUp(false);
                        current.Use();
                    }
                }
            }
            else
            {
                SpriteUtility.DragType dragType = (!current.alt) ? SpriteUtility.DragType.SpriteAnimation : SpriteUtility.DragType.CreateMultiple;
                if (SpriteUtility.s_DragType != dragType || SpriteUtility.s_SceneDragObjects == null)
                {
                    Sprite[] spriteFromDraggedPathsOrObjects2 = SpriteUtility.GetSpriteFromDraggedPathsOrObjects();
                    if (spriteFromDraggedPathsOrObjects2 == null || spriteFromDraggedPathsOrObjects2.Length == 0)
                    {
                        return;
                    }
                    Sprite x = spriteFromDraggedPathsOrObjects2[0];
                    if (x == null)
                    {
                        return;
                    }
                    if (SpriteUtility.s_DragType != SpriteUtility.DragType.NotInitialized)
                    {
                        SpriteUtility.CleanUp(true);
                    }
                    SpriteUtility.s_DragType         = dragType;
                    SpriteUtility.s_SceneDragObjects = new List <UnityEngine.Object>();
                    if (SpriteUtility.s_DragType == SpriteUtility.DragType.CreateMultiple)
                    {
                        Sprite[] array = spriteFromDraggedPathsOrObjects2;
                        for (int i = 0; i < array.Length; i++)
                        {
                            Sprite frame = array[i];
                            SpriteUtility.s_SceneDragObjects.Add(SpriteUtility.CreateDragGO(frame, Vector3.zero));
                        }
                    }
                    else
                    {
                        SpriteUtility.s_SceneDragObjects.Add(SpriteUtility.CreateDragGO(spriteFromDraggedPathsOrObjects2[0], Vector3.zero));
                    }
                    List <Transform> list = new List <Transform>();
                    using (List <UnityEngine.Object> .Enumerator enumerator2 = SpriteUtility.s_SceneDragObjects.GetEnumerator())
                    {
                        while (enumerator2.MoveNext())
                        {
                            GameObject gameObject3 = (GameObject)enumerator2.Current;
                            list.AddRange(gameObject3.GetComponentsInChildren <Transform>());
                            gameObject3.hideFlags = HideFlags.HideInHierarchy;
                        }
                    }
                    HandleUtility.ignoreRaySnapObjects = list.ToArray();
                }
                Vector3 position = Vector3.zero;
                position = HandleUtility.GUIPointToWorldRay(current.mousePosition).GetPoint(10f);
                if (sceneView.in2DMode)
                {
                    position.z = 0f;
                }
                else
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                    object obj = HandleUtility.RaySnap(HandleUtility.GUIPointToWorldRay(current.mousePosition));
                    if (obj != null)
                    {
                        position = ((RaycastHit)obj).point;
                    }
                }
                using (List <UnityEngine.Object> .Enumerator enumerator3 = SpriteUtility.s_SceneDragObjects.GetEnumerator())
                {
                    while (enumerator3.MoveNext())
                    {
                        GameObject gameObject4 = (GameObject)enumerator3.Current;
                        gameObject4.transform.position = position;
                    }
                }
                DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                current.Use();
            }
        }
        public void OnSceneDrag(SceneView sceneView)
        {
            GameObject target = this.target as GameObject;

            switch (PrefabUtility.GetPrefabType((UnityEngine.Object)target))
            {
            case PrefabType.Prefab:
            case PrefabType.ModelPrefab:
                Event current = Event.current;
                switch (current.type)
                {
                case EventType.DragUpdated:
                    if ((UnityEngine.Object)GameObjectInspector.dragObject == (UnityEngine.Object)null)
                    {
                        GameObjectInspector.dragObject           = (GameObject)PrefabUtility.InstantiatePrefab((UnityEngine.Object)PrefabUtility.FindPrefabRoot(target));
                        HandleUtility.ignoreRaySnapObjects       = GameObjectInspector.dragObject.GetComponentsInChildren <Transform>();
                        GameObjectInspector.dragObject.hideFlags = HideFlags.HideInHierarchy;
                        GameObjectInspector.dragObject.name      = target.name;
                    }
                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                    object obj = HandleUtility.RaySnap(HandleUtility.GUIPointToWorldRay(current.mousePosition));
                    if (obj != null)
                    {
                        RaycastHit raycastHit = (RaycastHit)obj;
                        float      num1       = 0.0f;
                        if (Tools.pivotMode == PivotMode.Center)
                        {
                            float num2 = HandleUtility.CalcRayPlaceOffset(HandleUtility.ignoreRaySnapObjects, raycastHit.normal);
                            if ((double)num2 != double.PositiveInfinity)
                            {
                                num1 = Vector3.Dot(GameObjectInspector.dragObject.transform.position, raycastHit.normal) - num2;
                            }
                        }
                        GameObjectInspector.dragObject.transform.position = Matrix4x4.identity.MultiplyPoint(raycastHit.point + raycastHit.normal * num1);
                    }
                    else
                    {
                        GameObjectInspector.dragObject.transform.position = HandleUtility.GUIPointToWorldRay(current.mousePosition).GetPoint(10f);
                    }
                    if (sceneView.in2DMode)
                    {
                        Vector3 position = GameObjectInspector.dragObject.transform.position;
                        position.z = PrefabUtility.FindPrefabRoot(target).transform.position.z;
                        GameObjectInspector.dragObject.transform.position = position;
                    }
                    current.Use();
                    return;

                case EventType.DragPerform:
                    string uniqueNameForSibling = GameObjectUtility.GetUniqueNameForSibling((Transform)null, GameObjectInspector.dragObject.name);
                    GameObjectInspector.dragObject.hideFlags = HideFlags.None;
                    Undo.RegisterCreatedObjectUndo((UnityEngine.Object)GameObjectInspector.dragObject, "Place " + GameObjectInspector.dragObject.name);
                    EditorUtility.SetDirty((UnityEngine.Object)GameObjectInspector.dragObject);
                    DragAndDrop.AcceptDrag();
                    Selection.activeObject             = (UnityEngine.Object)GameObjectInspector.dragObject;
                    HandleUtility.ignoreRaySnapObjects = (Transform[])null;
                    EditorWindow.mouseOverWindow.Focus();
                    GameObjectInspector.dragObject.name = uniqueNameForSibling;
                    GameObjectInspector.dragObject      = (GameObject)null;
                    current.Use();
                    return;

                case EventType.DragExited:
                    if (!(bool)((UnityEngine.Object)GameObjectInspector.dragObject))
                    {
                        return;
                    }
                    UnityEngine.Object.DestroyImmediate((UnityEngine.Object)GameObjectInspector.dragObject, false);
                    HandleUtility.ignoreRaySnapObjects = (Transform[])null;
                    GameObjectInspector.dragObject     = (GameObject)null;
                    current.Use();
                    return;

                default:
                    return;
                }
            }
        }
        public static void OnSceneDrag(SceneView sceneView)
        {
            Event current1 = Event.current;

            if (current1.type != EventType.DragUpdated && current1.type != EventType.DragPerform && current1.type != EventType.DragExited)
            {
                return;
            }
            if (!sceneView.in2DMode)
            {
                GameObject gameObject = HandleUtility.PickGameObject(Event.current.mousePosition, true);
                if ((UnityEngine.Object)gameObject != (UnityEngine.Object)null && DragAndDrop.objectReferences.Length == 1 && ((UnityEngine.Object)(DragAndDrop.objectReferences[0] as Texture) != (UnityEngine.Object)null && (UnityEngine.Object)gameObject.GetComponent <Renderer>() != (UnityEngine.Object)null))
                {
                    return;
                }
            }
            switch (current1.type)
            {
            case EventType.DragUpdated:
                SpriteUtility.DragType dragType = !current1.alt ? SpriteUtility.DragType.SpriteAnimation : SpriteUtility.DragType.CreateMultiple;
                if (SpriteUtility.s_DragType != dragType || SpriteUtility.s_SceneDragObjects == null)
                {
                    Sprite[] draggedPathsOrObjects = SpriteUtility.GetSpriteFromDraggedPathsOrObjects();
                    if (draggedPathsOrObjects == null || draggedPathsOrObjects.Length == 0 || (UnityEngine.Object)draggedPathsOrObjects[0] == (UnityEngine.Object)null)
                    {
                        break;
                    }
                    if (SpriteUtility.s_DragType != SpriteUtility.DragType.NotInitialized)
                    {
                        SpriteUtility.CleanUp();
                    }
                    SpriteUtility.s_DragType         = dragType;
                    SpriteUtility.s_SceneDragObjects = new List <UnityEngine.Object>();
                    if (SpriteUtility.s_DragType == SpriteUtility.DragType.CreateMultiple)
                    {
                        foreach (Sprite frame in draggedPathsOrObjects)
                        {
                            SpriteUtility.s_SceneDragObjects.Add((UnityEngine.Object)SpriteUtility.CreateDragGO(frame, Vector3.zero));
                        }
                    }
                    else
                    {
                        SpriteUtility.s_SceneDragObjects.Add((UnityEngine.Object)SpriteUtility.CreateDragGO(draggedPathsOrObjects[0], Vector3.zero));
                    }
                    List <Transform> transformList = new List <Transform>();
                    using (List <UnityEngine.Object> .Enumerator enumerator = SpriteUtility.s_SceneDragObjects.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            GameObject current2 = (GameObject)enumerator.Current;
                            transformList.AddRange((IEnumerable <Transform>)current2.GetComponentsInChildren <Transform>());
                            current2.hideFlags = HideFlags.HideInHierarchy;
                        }
                    }
                    HandleUtility.ignoreRaySnapObjects = transformList.ToArray();
                }
                Vector3 zero  = Vector3.zero;
                Vector3 point = HandleUtility.GUIPointToWorldRay(current1.mousePosition).GetPoint(10f);
                if (sceneView.in2DMode)
                {
                    point.z = 0.0f;
                }
                else
                {
                    DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                    object obj = HandleUtility.RaySnap(HandleUtility.GUIPointToWorldRay(current1.mousePosition));
                    if (obj != null)
                    {
                        point = ((RaycastHit)obj).point;
                    }
                }
                using (List <UnityEngine.Object> .Enumerator enumerator = SpriteUtility.s_SceneDragObjects.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        ((GameObject)enumerator.Current).transform.position = point;
                    }
                }
                DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
                current1.Use();
                break;

            case EventType.DragPerform:
                Sprite[] draggedPathsOrObjects1 = SpriteUtility.GetSpriteFromDraggedPathsOrObjects();
                if (draggedPathsOrObjects1 == null || SpriteUtility.s_SceneDragObjects == null)
                {
                    break;
                }
                if (SpriteUtility.s_DragType == SpriteUtility.DragType.SpriteAnimation)
                {
                    SpriteUtility.AddAnimationToGO((GameObject)SpriteUtility.s_SceneDragObjects[0], draggedPathsOrObjects1);
                }
                using (List <UnityEngine.Object> .Enumerator enumerator = SpriteUtility.s_SceneDragObjects.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        GameObject current2 = (GameObject)enumerator.Current;
                        Undo.RegisterCreatedObjectUndo((UnityEngine.Object)current2, "Create Sprite");
                        current2.hideFlags = HideFlags.None;
                    }
                }
                Selection.objects = SpriteUtility.s_SceneDragObjects.ToArray();
                SpriteUtility.CleanUp();
                current1.Use();
                break;

            case EventType.DragExited:
                if (SpriteUtility.s_SceneDragObjects == null || SpriteUtility.s_SceneDragObjects == null)
                {
                    break;
                }
                using (List <UnityEngine.Object> .Enumerator enumerator = SpriteUtility.s_SceneDragObjects.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        UnityEngine.Object.DestroyImmediate(enumerator.Current, false);
                    }
                }
                SpriteUtility.CleanUp();
                current1.Use();
                break;
            }
        }