void CreateGizmoObject()
    {
        LevelGizmo levelGizmo = FindObjectOfType <LevelGizmo>();

        if (levelGizmo == null)
        {
            new GameObject("LevelGizmo").AddComponent <LevelGizmo>();
        }
    }
    public void SceneGUI(SceneView sceneView)
    {
        e        = Event.current;
        in2DMode = sceneView.in2DMode;

        if (e.modifiers != EventModifiers.None)
        {
            isHoldingAlt    = true;
            mouseButtonDown = false;
        }
        else
        {
            isHoldingAlt = false;
        }

        Vector3 currentPos = GetPosition(e.mousePosition);

        if (selGridInt != 1)
        {
            currentPos += (Vector3.back * spawnHeight);
            currentPos  = Utils.AvoidIntersect(currentPos);
        }

        HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive));
        var controlID = GUIUtility.GetControlID(FocusType.Passive);
        var eventType = e.GetTypeForControl(controlID);

        if (SceneView.mouseOverWindow != sceneView)
        {
            Reset();
        }
        if (e.isKey && e.keyCode == KeyCode.P)
        {
            EditorApplication.ExecuteMenuItem("Edit/Play");
        }

        if (isHoldingAlt)
        {
            if (eventType == EventType.ScrollWheel)
            {
                int deltaY = (e.delta.y < 0) ? -1 : 1;
                spawnHeight += deltaY;
                currentPos  += (Vector3.back * deltaY);
                e.Use();
            }
        }
        else
        {
            if (eventType == EventType.MouseUp)
            {
                mouseButtonDown = false;
            }

            if (eventType == EventType.MouseDown)
            {
                if (e.button == 0 && selGridInt != 0)
                {
                    e.Use();
                    Refresh();
                    drawPos = currentPos;
                    CreateObject(Utils.Vec3ToInt(drawPos));
                    mouseButtonDown = true;
                    mousePosOnClick = e.mousePosition;
                }
                else if (e.button == 1)
                {
                    selGridInt = 0;
                    Ray        ray = HandleUtility.GUIPointToWorldRay(e.mousePosition);
                    RaycastHit hit = new RaycastHit();

                    if (Physics.Raycast(ray, out hit, 1000.0f))
                    {
                        for (int i = 0; i < prefabs.Length; i++)
                        {
                            if (prefabs[i].transform.name == hit.transform.parent.name)
                            {
                                selGridInt = i + 2;
                            }
                        }
                    }
                }
            }
            else if (mouseButtonDown)
            {
                if (Vector2.Distance(mousePosOnClick, e.mousePosition) > 10f)
                {
                    if (!Utils.VectorRoughly2D(drawPos, currentPos, 0.75f))
                    {
                        drawPos = Utils.Vec3ToInt(currentPos);
                        CreateObject(drawPos);
                        mousePosOnClick = e.mousePosition;
                    }
                }
            }
        }

        LevelGizmo.UpdateGizmo(currentPos, gizmoColor);
        LevelGizmo.Enable(selGridInt != 0);
        sceneView.Repaint();
        Repaint();
    }