Пример #1
0
        private static Rect ClearCamera(SceneView sceneView, Color clearColor)
        {
            Rect cameraRect = GetCameraRect(sceneView: sceneView);

            Rect groupSpaceCameraRect         = new Rect(x: 0, y: 0, width: cameraRect.width, height: cameraRect.height);
            Rect groupSpaceCameraRectInPixels = EditorGUIUtility.PointsToPixels(rect: groupSpaceCameraRect);

            CameraClearFlags oldClearFlags = sceneView.camera.clearFlags;
            Color            oldClearColor = sceneView.camera.backgroundColor;

            sceneView.camera.clearFlags      = CameraClearFlags.SolidColor;
            sceneView.camera.backgroundColor = clearColor;
            Handles.ClearCamera(position: groupSpaceCameraRectInPixels, camera: sceneView.camera);
            sceneView.camera.clearFlags      = oldClearFlags;
            sceneView.camera.backgroundColor = oldClearColor;

            return(cameraRect);
        }
Пример #2
0
        private void OnGUI()
        {
            onGUIDelegate(this);
            SceneViewUtilities.ResetOnGUIState();

            SetupCamera();

            Rect guiRect    = new Rect(0, 0, position.width, position.height);
            Rect cameraRect = EditorGUIUtility.PointsToPixels(guiRect);

            PrepareCameraTargetTexture(cameraRect);
            Handles.ClearCamera(cameraRect, m_Camera);

            m_Camera.cullingMask = Tools.visibleLayers;

            // Draw camera
            bool pushedGUIClip;

            DoDrawCamera(guiRect, out pushedGUIClip);

            SceneViewUtilities.BlitRT(m_SceneTargetTexture, guiRect, pushedGUIClip);
        }
    public override void OnGUI()
    {
        if (!(containerWindow is SceneView view))
        {
            return;
        }

        Rect gizmoRect = new Rect(0, 0, kRotationSize, kRotationSize);

        GUILayoutUtility.GetRect(gizmoRect.width, gizmoRect.height + kPerspOrthoLabelHeight);

        Event evt = Event.current;

        if (evt.type == EventType.MouseDown && evt.button == 1 &&
            !view.in2DMode &&
            !view.isRotationLocked &&
            gizmoRect.Contains(evt.mousePosition))
        {
            DisplayContextMenu(new Rect(evt.mousePosition.x, evt.mousePosition.y, 0, 0), view);
            evt.Use();
        }

        // Usually this does nothing, but when dragging the window between monitors that have different scaling
        // it can resize the RT as necessary.
        SetupRenderTexture();
        SetupCamera(view);

        //Handle transparency when rotation is locked
        using (new BlendingScope(
                   view.isRotationLocked ? BlendMode.One : BlendMode.SrcAlpha,
                   view.isRotationLocked ? BlendMode.Zero : BlendMode.OneMinusSrcAlpha))
        {
            using (new GUI.GroupScope(gizmoRect))
            {
                var temp = RenderTexture.active;
                Handles.SetCamera(gizmoRect, m_Camera);

                if (evt.type == EventType.Repaint)
                {
                    RenderTexture.active = m_RenderTexture;
                    GL.Clear(false, true, k_RTBackground);
                    Handles.ClearCamera(gizmoRect, m_Camera);
                    GUIClip.Internal_PushParentClip(Matrix4x4.identity, GUIClip.GetParentMatrix(), gizmoRect);
                }

                DoOrientationHandles(view, m_Camera);

                if (evt.type == EventType.Repaint)
                {
                    GUIClip.Internal_PopParentClip();
                }

                RenderTexture.active = temp;
            }

            GUI.Label(gizmoRect, m_RenderTexture);

            Rect labelRect = gizmoRect;
            labelRect.y += gizmoRect.height;
            DrawLabels(view, labelRect);
        }
    }
Пример #4
0
 public void Clear()
 {
     Handles.ClearCamera(Position, Camera);
 }
Пример #5
0
        private void OnSceneGUI()
        {
            //stop the scene GUI when in playmode, it f***s shit up.
            if (Application.isPlaying)
            {
                return;
            }
            //clear the scene view and re-draw it for better visibility.
            Camera cam = SceneView.GetAllSceneCameras()[0];

            Handles.ClearCamera(new Rect(0, 0, 1000, 1000), cam);
            cam.Render();

            //if the pad is able to rotate and the inspector isnt in manual mode, show the pivot rotation handle.
            if (pad.CanRotate && !manualOverride)
            {
                //secondary direction
                Handles.color = Color.magenta;
                var seconDir = (!pad.IsSecondary? seconRotationProperty : primRotationProperty).quaternionValue * (!pad.IsSecondary ? vectorBProperty.vector3Value : vectorAProperty.vector3Value);
                Handles.DrawLine(transform.position, transform.position + seconDir);
                Handles.Label(transform.position + seconDir, (pad.IsSecondary ? "Primary" : "Secondary"));

                Quaternion oldRotation = pivot.rotation;
                var        rotation    = Handles.RotationHandle(pivot.rotation, transform.position + pivot.up * 2f);
                if (pad.IsSecondary)
                {
                    seconRotationProperty.quaternionValue = rotation;
                }
                else
                {
                    primRotationProperty.quaternionValue = rotation;
                }
                pivot.rotation = rotation;
                //set recalculate flag if the rotation has changed.
                recalculate = recalculate | oldRotation != rotation;
            }

            //i like cyan :)
            Handles.color = Color.cyan;

            //the active vector property to edit.
            var activeVector = pad.IsSecondary? vectorBProperty : vectorAProperty;

            //change the launch setting.
            Vector3 worldPosition = Handles.DoPositionHandle(pivot.TransformPoint(activeVector.vector3Value), pivot.rotation);
            Vector3 result        = pivot.InverseTransformPoint(worldPosition);
            Vector3 direction     = pivot.TransformVector(result);

            //Draw the arc.
            DrawArc(transform.position, direction);
            //Helper tangent line
            Handles.DrawLine(transform.position, worldPosition);
            if (recalculate || result != activeVector.vector3Value)
            {
                //Recalculate the landing point.
                landingZone = FindLandingZone(transform.position, direction);
            }
            result.x = 0;
            //Handles.DrawWireCube(result, Vector3.one);
            activeVector.vector3Value = result;

            serializedObject.ApplyModifiedProperties();
        }