added: axis enabled and gain settings to camera settings processor
This commit is contained in:
@@ -89,7 +89,63 @@ public struct FloatCameraValueGroup : ICameraValueGroup{
|
||||
}
|
||||
}
|
||||
|
||||
public struct BoolCameraValueGroup : ICameraValueGroup{
|
||||
public string label;
|
||||
public bool value;
|
||||
|
||||
public CameraSettingsToggle changeValue;
|
||||
|
||||
public BoolCameraValueGroup(string newLabel){
|
||||
label = newLabel;
|
||||
value = true;
|
||||
changeValue = CameraSettingsToggle.NoChange;
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public class BoolCameraValueGroupDrawer : ObjectDrawer<BoolCameraValueGroup> {
|
||||
public override BoolCameraValueGroup OnGUI(GUIContent content, BoolCameraValueGroup _instance){
|
||||
// Remove label for floats
|
||||
EditorGUIUtility.labelWidth = 50;
|
||||
|
||||
// Set layout options for the label and the float fields
|
||||
GUILayoutOption[] floatOptions = new GUILayoutOption[] {
|
||||
GUILayout.Width(80.0f),
|
||||
GUILayout.MinWidth(20.0f),
|
||||
GUILayout.ExpandWidth(true),
|
||||
};
|
||||
|
||||
GUILayoutOption[] labelOptions = new GUILayoutOption[]{
|
||||
GUILayout.Width(200.0f),
|
||||
};
|
||||
|
||||
// Start the Vertical layout then add the label before adding a horizontal so the label will be on top of side-by-side options
|
||||
GUILayout.BeginVertical();
|
||||
GUILayout.Label(_instance.ToString(), labelOptions);
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
// Create the x settings enum
|
||||
_instance.changeValue = (CameraSettingsToggle)EditorGUILayout.EnumPopup("", instance.changeValue);
|
||||
|
||||
// Create the value/disabled information field
|
||||
if (_instance.changeValue == CameraSettingsToggle.NewValue){
|
||||
_instance.value = EditorGUILayout.Toggle(_instance.value, floatOptions);
|
||||
} else {
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.TextField(_instance.changeValue == CameraSettingsToggle.NoChange ? "Unchanged" : "Reset", floatOptions);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
// Close this line up
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.EndVertical();
|
||||
|
||||
// Reset to default so the rest of things don't get messed up
|
||||
EditorGUIUtility.labelWidth = 0;
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
|
||||
public class FloatCameraValueGroupDrawer : ObjectDrawer<FloatCameraValueGroup> {
|
||||
public override FloatCameraValueGroup OnGUI(GUIContent _content, FloatCameraValueGroup _instance){
|
||||
// Remove label for floats
|
||||
@@ -338,6 +394,12 @@ namespace NodeCanvas.Tasks.Actions {
|
||||
public OrbitalFollowValueGroup orbitFollowTop = new (newLabel: "Top");
|
||||
public OrbitalFollowValueGroup orbitFollowCenter = new (newLabel: "Center");
|
||||
public OrbitalFollowValueGroup orbitFollowBottom = new (newLabel: "Bottom");
|
||||
|
||||
public BoolCameraValueGroup enableXAxis = new (newLabel: "Input Axis X Enabled");
|
||||
public BoolCameraValueGroup enableYAxis = new (newLabel: "Input Axis Y Enabled");
|
||||
|
||||
public FloatCameraValueGroup axisLookXGain = new (newLabel: "Look Orbit X Gain");
|
||||
public FloatCameraValueGroup axisLookYGain = new (newLabel: "Look Orbit Y Gain");
|
||||
|
||||
[ParadoxNotion.Design.Header("Rotation Composer Settings")]
|
||||
public Vector2CameraValueGroup screenPosition = new (newLabel: "Screen Position");
|
||||
@@ -362,11 +424,16 @@ namespace NodeCanvas.Tasks.Actions {
|
||||
UpdateVector3Value(cameraOffset, ref CameraSettingsProcessor.values.cameraOffsetOffset);
|
||||
|
||||
UpdateVector3Value(orbitPositionDamping, ref CameraSettingsProcessor.values.orbitPositionDamping);
|
||||
// UpdateVector3Value(orbitTargetOffset, ref CameraSettingsProcessor.values.orbitTargetOffset);
|
||||
UpdateVector3Value(orbitTargetOffset, ref CameraSettingsProcessor.values.orbitTargetOffset);
|
||||
|
||||
UpdateVector2Value(screenPosition, ref CameraSettingsProcessor.values.rotationComposerScreenPos);
|
||||
UpdateFloatValue(fieldOfView, ref CameraSettingsProcessor.values.mainFieldOfView);
|
||||
|
||||
UpdateFloatValue(axisLookXGain, ref CameraSettingsProcessor.values.axisLookGainX);
|
||||
UpdateFloatValue(axisLookYGain, ref CameraSettingsProcessor.values.axisLookGainY);
|
||||
|
||||
|
||||
|
||||
EndAction(true);
|
||||
}
|
||||
|
||||
@@ -438,7 +505,18 @@ namespace NodeCanvas.Tasks.Actions {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void UpdateBoolValue(BoolCameraValueGroup valueGroup, ref CameraSettingSingleValue<bool> targetProperty){
|
||||
switch (valueGroup.changeValue) {
|
||||
case CameraSettingsToggle.NewValue:
|
||||
targetProperty.targetValue = valueGroup.value;
|
||||
break;
|
||||
case CameraSettingsToggle.ResetValue:
|
||||
targetProperty.targetValue = targetProperty.originalValue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateFloatValue(FloatCameraValueGroup valueGroup, ref CameraSettingSingleValue<float> targetProperty){
|
||||
switch (valueGroup.changeValue) {
|
||||
case CameraSettingsToggle.NewValue:
|
||||
|
||||
@@ -32,6 +32,12 @@ public struct CameraSettingValues{
|
||||
public CameraSettingSingleValue<Vector3> orbitPositionDamping;
|
||||
public CameraSettingSingleValue<Vector3> orbitTargetOffset;
|
||||
|
||||
public CameraSettingSingleValue<bool> axisLookEnabledX;
|
||||
public CameraSettingSingleValue<bool> axisLookEnabledY;
|
||||
|
||||
public CameraSettingSingleValue<float> axisLookGainX;
|
||||
public CameraSettingSingleValue<float> axisLookGainY;
|
||||
|
||||
public CameraSettingSingleValue<float> orbitFollowTopHeight;
|
||||
public CameraSettingSingleValue<float> orbitFollowTopRadius;
|
||||
public CameraSettingSingleValue<float> orbitFollowCenterHeight;
|
||||
@@ -48,6 +54,12 @@ public struct CameraSettingValues{
|
||||
|
||||
orbitPositionDamping = new CameraSettingSingleValue<Vector3>(defaultSmoothing);
|
||||
orbitTargetOffset = new CameraSettingSingleValue<Vector3>(defaultSmoothing);
|
||||
|
||||
axisLookEnabledX = new CameraSettingSingleValue<bool>();
|
||||
axisLookEnabledY = new CameraSettingSingleValue<bool>();
|
||||
|
||||
axisLookGainX = new CameraSettingSingleValue<float>(defaultSmoothing);
|
||||
axisLookGainY = new CameraSettingSingleValue<float>(defaultSmoothing);
|
||||
|
||||
orbitFollowTopHeight = new CameraSettingSingleValue<float>(defaultSmoothing);
|
||||
orbitFollowTopRadius = new CameraSettingSingleValue<float>(defaultSmoothing);
|
||||
@@ -72,6 +84,7 @@ public class CameraSettingsProcessor : MonoBehaviour{
|
||||
private CinemachineOrbitalFollow orbit;
|
||||
private CinemachineRotationComposer rotComp;
|
||||
private CinemachineCameraOffset offset;
|
||||
private CinemachineInputAxisController axisCont;
|
||||
|
||||
public void Awake(){
|
||||
// Singleton management
|
||||
@@ -87,11 +100,16 @@ public class CameraSettingsProcessor : MonoBehaviour{
|
||||
orbit = mainCamera.GetComponent<CinemachineOrbitalFollow>();
|
||||
rotComp = mainCamera.GetComponent<CinemachineRotationComposer>();
|
||||
offset = mainCamera.GetComponent<CinemachineCameraOffset>();
|
||||
axisCont = mainCamera.GetComponent<CinemachineInputAxisController>();
|
||||
|
||||
// Initialize camera settings values
|
||||
values = new CameraSettingValues{
|
||||
cameraOffsetOffset = new CameraSettingSingleValue<Vector3>(defaultSmoothing: .2f, offset.Offset),
|
||||
mainFieldOfView = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, main.Lens.FieldOfView),
|
||||
axisLookEnabledX = new CameraSettingSingleValue<bool>(0f, axisCont.Controllers[0].Enabled),
|
||||
axisLookEnabledY = new CameraSettingSingleValue<bool>(0f, axisCont.Controllers[1].Enabled),
|
||||
axisLookGainX = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, axisCont.Controllers[0].Input.Gain),
|
||||
axisLookGainY = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, axisCont.Controllers[1].Input.Gain),
|
||||
orbitPositionDamping = new CameraSettingSingleValue<Vector3>(defaultSmoothing: .2f, orbit.TrackerSettings.PositionDamping),
|
||||
orbitFollowTopHeight = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, orbit.Orbits.Top.Height),
|
||||
orbitFollowTopRadius = new CameraSettingSingleValue<float>(defaultSmoothing: .2f, orbit.Orbits.Top.Radius),
|
||||
@@ -107,6 +125,18 @@ public class CameraSettingsProcessor : MonoBehaviour{
|
||||
main.Lens.FieldOfView = Mathf.SmoothDamp(main.Lens.FieldOfView,
|
||||
values.mainFieldOfView.targetValue, ref values.mainFieldOfView.velocityRef,
|
||||
values.mainFieldOfView.smoothing);
|
||||
|
||||
axisCont.Controllers[0].Enabled = values.axisLookEnabledX.targetValue;
|
||||
|
||||
axisCont.Controllers[1].Enabled = values.axisLookEnabledY.targetValue;
|
||||
|
||||
axisCont.Controllers[0].Input.Gain = Mathf.SmoothDamp(axisCont.Controllers[0].Input.Gain,
|
||||
values.axisLookGainX.targetValue, ref values.axisLookGainX.velocityRef,
|
||||
values.axisLookGainX.smoothing);
|
||||
|
||||
axisCont.Controllers[1].Input.Gain = Mathf.SmoothDamp(axisCont.Controllers[1].Input.Gain,
|
||||
values.axisLookGainY.targetValue, ref values.axisLookGainY.velocityRef,
|
||||
values.axisLookGainY.smoothing);
|
||||
|
||||
orbit.TargetOffset = Vector3.SmoothDamp(orbit.TargetOffset,
|
||||
values.orbitTargetOffset.targetValue, ref values.orbitTargetOffset.velocityRefV3,
|
||||
@@ -147,6 +177,8 @@ public class CameraSettingsProcessor : MonoBehaviour{
|
||||
offset.Offset = Vector3.SmoothDamp(offset.Offset,
|
||||
values.cameraOffsetOffset.targetValue, ref values.cameraOffsetOffset.velocityRefV3,
|
||||
values.cameraOffsetOffset.smoothing);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Update(){
|
||||
|
||||
Reference in New Issue
Block a user