UnityEditor.SceneViewMotion.ArrowKeys C# (CSharp) Method

ArrowKeys() public static method

public static ArrowKeys ( SceneView sv ) : void
sv SceneView
return void
        public static void ArrowKeys(SceneView sv)
        {
            Event current = Event.current;
            int controlID = GUIUtility.GetControlID(FocusType.Passive);
            if (((GUIUtility.hotControl == 0) || (GUIUtility.hotControl == controlID)) && !EditorGUI.actionKey)
            {
                EventType typeForControl = current.GetTypeForControl(controlID);
                if (typeForControl == EventType.KeyDown)
                {
                    switch (current.keyCode)
                    {
                        case KeyCode.UpArrow:
                            sv.viewIsLockedToObject = false;
                            if (!sv.m_Ortho.value)
                            {
                                s_Motion.z = 1f;
                            }
                            else
                            {
                                s_Motion.y = 1f;
                            }
                            GUIUtility.hotControl = controlID;
                            current.Use();
                            return;

                        case KeyCode.DownArrow:
                            sv.viewIsLockedToObject = false;
                            if (!sv.m_Ortho.value)
                            {
                                s_Motion.z = -1f;
                            }
                            else
                            {
                                s_Motion.y = -1f;
                            }
                            GUIUtility.hotControl = controlID;
                            current.Use();
                            return;

                        case KeyCode.RightArrow:
                            sv.viewIsLockedToObject = false;
                            s_Motion.x = 1f;
                            GUIUtility.hotControl = controlID;
                            current.Use();
                            break;

                        case KeyCode.LeftArrow:
                            sv.viewIsLockedToObject = false;
                            s_Motion.x = -1f;
                            GUIUtility.hotControl = controlID;
                            current.Use();
                            break;
                    }
                }
                else if (typeForControl == EventType.KeyUp)
                {
                    if (GUIUtility.hotControl == controlID)
                    {
                        switch (current.keyCode)
                        {
                            case KeyCode.UpArrow:
                            case KeyCode.DownArrow:
                                s_Motion.z = 0f;
                                s_Motion.y = 0f;
                                current.Use();
                                break;

                            case KeyCode.RightArrow:
                            case KeyCode.LeftArrow:
                                s_Motion.x = 0f;
                                current.Use();
                                break;
                        }
                    }
                }
                else if ((typeForControl == EventType.Layout) && (GUIUtility.hotControl == controlID))
                {
                    Vector3 forward;
                    if (!sv.m_Ortho.value)
                    {
                        forward = Camera.current.transform.forward + ((Vector3) (Camera.current.transform.up * 0.3f));
                        forward.y = 0f;
                        forward.Normalize();
                    }
                    else
                    {
                        forward = Camera.current.transform.forward;
                    }
                    Vector3 movementDirection = GetMovementDirection();
                    sv.LookAtDirect(sv.pivot + (Quaternion.LookRotation(forward) * movementDirection), sv.rotation);
                    if (s_Motion.sqrMagnitude == 0f)
                    {
                        sv.pivot = sv.pivot;
                        s_FlySpeed = 0f;
                        GUIUtility.hotControl = 0;
                    }
                    else
                    {
                        sv.Repaint();
                    }
                }
            }
        }