- Home /
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?
Comment