public void UpdateCameraSnap() { if (KickStarter.mainCamera) { Camera targetCamera = GetComponent <Camera>(); KickStarter.mainCamera.transform.position = transform.position; KickStarter.mainCamera.transform.rotation = transform.rotation; KickStarter.mainCamera.Camera.orthographic = targetCamera.orthographic; KickStarter.mainCamera.Camera.fieldOfView = targetCamera.fieldOfView; KickStarter.mainCamera.Camera.farClipPlane = targetCamera.farClipPlane; KickStarter.mainCamera.Camera.nearClipPlane = targetCamera.nearClipPlane; KickStarter.mainCamera.Camera.orthographicSize = targetCamera.orthographicSize; #if ALLOW_PHYSICAL_CAMERA KickStarter.mainCamera.Camera.ResetProjectionMatrix(); KickStarter.mainCamera.Camera.usePhysicalProperties = targetCamera.usePhysicalProperties; if (targetCamera.usePhysicalProperties) { KickStarter.mainCamera.Camera.sensorSize = targetCamera.sensorSize; KickStarter.mainCamera.Camera.lensShift = targetCamera.lensShift; } #endif if (MainCamera.AllowProjectionShifting(targetCamera)) { Camera.main.projectionMatrix = AdvGame.SetVanishingPoint(Camera.main, perspectiveOffset, true); } } }
private void SetProjection() { if (MainCamera.AllowProjectionShifting(Camera)) { Camera.projectionMatrix = AdvGame.SetVanishingPoint(Camera, perspectiveOffset); } }
public override void OnInspectorGUI() { GameCamera25D _target = (GameCamera25D)target; CustomGUILayout.BeginVertical(); EditorGUILayout.LabelField("Background image", EditorStyles.boldLabel); EditorGUILayout.BeginHorizontal(); _target.backgroundImage = (BackgroundImage)CustomGUILayout.ObjectField <BackgroundImage> ("Background:", _target.backgroundImage, true, "", "The BackgroundImage to display underneath all scene objects"); if (_target.backgroundImage) { if (!Application.isPlaying && GUILayout.Button("Set as active", GUILayout.MaxWidth(90f))) { Undo.RecordObject(_target, "Set active background"); _target.SetActiveBackground(); } } else { if (GUILayout.Button("Create", GUILayout.MaxWidth(90f))) { Undo.RecordObject(_target, "Create Background Image"); BackgroundImage newBackgroundImage = SceneManager.AddPrefab("SetGeometry", "BackgroundImage", true, false, true).GetComponent <BackgroundImage>(); string cameraName = _target.gameObject.name; newBackgroundImage.gameObject.name = AdvGame.UniqueName(cameraName + ": Background"); _target.backgroundImage = newBackgroundImage; } } EditorGUILayout.EndHorizontal(); if (MainCamera.AllowProjectionShifting(_target.GetComponent <Camera>())) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Perspective offset", EditorStyles.boldLabel); _target.perspectiveOffset.x = CustomGUILayout.Slider("Horizontal:", _target.perspectiveOffset.x, -0.05f, 0.05f, "", "The horizontal offset in perspective from the camera's centre"); _target.perspectiveOffset.y = CustomGUILayout.Slider("Vertical:", _target.perspectiveOffset.y, -0.05f, 0.05f, "", "The vertical offset in perspective from the camera's centre"); } CustomGUILayout.EndVertical(); if (_target.isActiveEditor) { _target.UpdateCameraSnap(); } UnityVersionHandler.CustomSetDirty(_target); }