change: finished and cleaned all settings changes, code commented, smoothing and easing are now exponential
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using Reset.Core;
|
||||
using Sirenix.OdinInspector;
|
||||
using Unity.Cinemachine;
|
||||
@@ -6,14 +7,8 @@ using UnityEngine;
|
||||
public class CameraSettingsProcessor : MonoBehaviour{
|
||||
public static CameraSettingsProcessor Instance{ get; private set; }
|
||||
|
||||
[HideInInspector] public static CameraSettingData data;
|
||||
[HideInInspector] public static CameraSettingData original;
|
||||
[ShowInInspector] public static CameraSettingData smoothing;
|
||||
[ShowInInspector] public static CameraSettingData easing;
|
||||
|
||||
|
||||
[HideInInspector] public static CameraSettingData currentSmoothing;
|
||||
[HideInInspector] public static CameraSettingData currentValue;
|
||||
[ShowInInspector, FoldoutGroup("Camera Data", expanded: true), InlineProperty, HideLabel]
|
||||
public CameraSettingData data;
|
||||
|
||||
public static GameObject mainCamera;
|
||||
|
||||
@@ -38,59 +33,32 @@ public class CameraSettingsProcessor : MonoBehaviour{
|
||||
rotComp = mainCamera.GetComponent<CinemachineRotationComposer>();
|
||||
offset = mainCamera.GetComponent<CinemachineCameraOffset>();
|
||||
axisCont = mainCamera.GetComponent<CinemachineInputAxisController>();
|
||||
|
||||
|
||||
// Quick check for a camera settings
|
||||
if (data == null) {
|
||||
Debug.LogWarning("No Camera Settings Data was found on processing. One will be created. Is this intentional? This will have strong effects on camera movement");
|
||||
data = new CameraSettingData();
|
||||
}
|
||||
|
||||
// Initialize camera settings values from current values
|
||||
data.mainFieldOfView.targetValue = main.Lens.FieldOfView;
|
||||
|
||||
data.orbitPositionDamping.targetValue = orbit.TrackerSettings.PositionDamping;
|
||||
data.orbitTargetOffset.targetValue = orbit.TargetOffset;
|
||||
|
||||
data.axisLookEnabledX.targetValue = axisCont.Controllers[0].Enabled;
|
||||
data.axisLookEnabledY.targetValue = axisCont.Controllers[1].Enabled;
|
||||
|
||||
data.axisLookGainX.targetValue = axisCont.Controllers[0].Input.Gain;
|
||||
data.axisLookGainY.targetValue = axisCont.Controllers[1].Input.Gain;
|
||||
|
||||
data.orbitFollowTopHeight.targetValue = orbit.Orbits.Top.Height;
|
||||
data.orbitFollowTopRadius.targetValue = orbit.Orbits.Top.Radius;
|
||||
data.orbitFollowCenterHeight.targetValue = orbit.Orbits.Center.Height;
|
||||
data.orbitFollowCenterRadius.targetValue = orbit.Orbits.Center.Radius;
|
||||
data.orbitFollowBottomHeight.targetValue = orbit.Orbits.Bottom.Height;
|
||||
data.orbitFollowBottomRadius.targetValue = orbit.Orbits.Bottom.Radius;
|
||||
|
||||
data.rotationComposerScreenPos.targetValue = rotComp.Composition.ScreenPosition;
|
||||
data.cameraOffsetOffset.targetValue = offset.Offset;
|
||||
|
||||
// And copy to the original
|
||||
original = (CameraSettingData)data.Clone();
|
||||
InitializeAllSettings();
|
||||
}
|
||||
|
||||
|
||||
void Update(){
|
||||
// EaseToNewSmoothingValues();
|
||||
// ProcessCameraValues();
|
||||
SmoothCameraSettings();
|
||||
ApplyCameraSettings();
|
||||
}
|
||||
|
||||
void EaseToNewSmoothingValues(){
|
||||
data.mainFieldOfView.SmoothAndEase();
|
||||
|
||||
data.orbitPositionDamping.SmoothAndEase();
|
||||
data.orbitTargetOffset.SmoothAndEase();
|
||||
|
||||
data.axisLookGainX.SmoothAndEase();
|
||||
data.axisLookGainY.SmoothAndEase();
|
||||
|
||||
data.orbitFollowTopHeight.SmoothAndEase();
|
||||
data.orbitFollowTopRadius.SmoothAndEase();
|
||||
data.orbitFollowCenterHeight.SmoothAndEase();
|
||||
data.orbitFollowCenterRadius.SmoothAndEase();
|
||||
data.orbitFollowBottomHeight.SmoothAndEase();
|
||||
data.orbitFollowBottomRadius.SmoothAndEase();
|
||||
void SmoothCameraSettings(){
|
||||
var settings = data.GetAllSettings();
|
||||
|
||||
data.rotationComposerScreenPos.SmoothAndEase();
|
||||
data.cameraOffsetOffset.SmoothAndEase();
|
||||
for (int i = 0; i < settings.Count; i++) {
|
||||
settings[i].SmoothAndEase();
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessCameraValues(){
|
||||
// Responsible for actively applying the settings to the Cinemachine components
|
||||
void ApplyCameraSettings(){
|
||||
main.Lens.FieldOfView = data.mainFieldOfView.Value;
|
||||
|
||||
axisCont.Controllers[0].Enabled = data.axisLookEnabledX.Value;
|
||||
@@ -113,9 +81,30 @@ public class CameraSettingsProcessor : MonoBehaviour{
|
||||
|
||||
offset.Offset = data.cameraOffsetOffset.Value;
|
||||
}
|
||||
|
||||
|
||||
[Button]
|
||||
void InitializeAllSettings(){
|
||||
data.mainFieldOfView.targetValue = main.Lens.FieldOfView;
|
||||
|
||||
data.orbitPositionDamping.targetValue = orbit.TrackerSettings.PositionDamping;
|
||||
data.orbitTargetOffset.targetValue = orbit.TargetOffset;
|
||||
|
||||
data.axisLookEnabledX.targetValue = axisCont.Controllers[0].Enabled;
|
||||
data.axisLookEnabledY.targetValue = axisCont.Controllers[1].Enabled;
|
||||
|
||||
data.axisLookGainX.targetValue = axisCont.Controllers[0].Input.Gain;
|
||||
data.axisLookGainY.targetValue = axisCont.Controllers[1].Input.Gain;
|
||||
|
||||
data.orbitFollowTopHeight.targetValue = orbit.Orbits.Top.Height;
|
||||
data.orbitFollowTopRadius.targetValue = orbit.Orbits.Top.Radius;
|
||||
data.orbitFollowCenterHeight.targetValue = orbit.Orbits.Center.Height;
|
||||
data.orbitFollowCenterRadius.targetValue = orbit.Orbits.Center.Radius;
|
||||
data.orbitFollowBottomHeight.targetValue = orbit.Orbits.Bottom.Height;
|
||||
data.orbitFollowBottomRadius.targetValue = orbit.Orbits.Bottom.Radius;
|
||||
|
||||
data.rotationComposerScreenPos.targetValue = rotComp.Composition.ScreenPosition;
|
||||
data.cameraOffsetOffset.targetValue = offset.Offset;
|
||||
|
||||
var allSettings = data.GetAllSettings();
|
||||
for (int i = 0; i < allSettings.Count; i++) {
|
||||
allSettings[i].Initialize();
|
||||
|
||||
Reference in New Issue
Block a user