x


Camera Projection Matrix - feeding back to itself results in different result

Here's 2 script to demonstrate the issue.

Whack this in your scripts directory and attach it to a camera:

using UnityEngine;

[ExecuteInEditMode, RequireComponent(typeof(Camera))]
public class CameraMatrixTest : MonoBehaviour
{
    public void Go()
    {
        var m = camera.projectionMatrix;

        camera.projectionMatrix = m;
    }

    public void Restore()
    {
        camera.ResetAspect();
        camera.ResetProjectionMatrix();
    }
}

And this in your Editor folder:

using UnityEditor;
using UnityEngine;

[CustomEditor(typeof(CameraMatrixTest))]
public class CameraMatrixTestEditor : Editor
{
    private CameraMatrixTest Target { get { return (CameraMatrixTest) target; } }


    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        if(GUILayout.Button("Go!")) Target.Go();
        if(GUILayout.Button("Reset")) Target.Restore();
    }
}

What I get is a flipped camera when assigned the camera's own perspective matrix back to itself! Is it a bug or am I missing a parameter?

more ▼

asked Oct 26 '10 at 08:55 AM

George gravatar image

George
285 10 11 19

(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2978
x80

asked: Oct 26 '10 at 08:55 AM

Seen: 1074 times

Last Updated: Oct 26 '10 at 08:55 AM