change: finished and cleaned all settings changes, code commented, smoothing and easing are now exponential
This commit is contained in:
@@ -9,32 +9,36 @@ namespace NodeCanvas.Tasks.Actions {
|
||||
[Category("Reset")]
|
||||
[Description("Change Cinemachine camera settings for the player")]
|
||||
public class ChangeCameraSettings : ActionTask{
|
||||
[ParadoxNotion.Design.Header("Main Settings")]
|
||||
[ParadoxNotion.Design.Header("Main Settings"), Space(8)]
|
||||
public FloatValueGroup fieldOfView = new (newLabel: "FOV");
|
||||
|
||||
[ParadoxNotion.Design.Header("Orbit Follow Ring Settings"), Space (5)]
|
||||
|
||||
public Vector3ValueGroup orbitTargetOffset = new(newLabel: "Target Offset");
|
||||
[Space(5)]public Vector3ValueGroup orbitPositionDamping = new(newLabel: "Position Damping");
|
||||
|
||||
public OrbitalFollowValueGroup orbitFollowTop = new (newLabel: "Top");
|
||||
public OrbitalFollowValueGroup orbitFollowCenter = new (newLabel: "Center");
|
||||
public OrbitalFollowValueGroup orbitFollowBottom = new (newLabel: "Bottom");
|
||||
|
||||
[ParadoxNotion.Design.Header("Orbit Follow Ring Settings"), Space (5)]
|
||||
public OrbitalFollowValueGroup orbitFollowTop = new (newLabel: "Top Ring");
|
||||
public OrbitalFollowValueGroup orbitFollowCenter = new (newLabel: "Top Ring");
|
||||
[Space(8)]
|
||||
public OrbitalFollowValueGroup orbitFollowBottom = new (newLabel: "Top Ring");
|
||||
|
||||
public BoolValueGroup enableXAxis = new (newLabel: "Input Axis X Enabled");
|
||||
public BoolValueGroup enableYAxis = new (newLabel: "Input Axis Y Enabled");
|
||||
|
||||
public FloatValueGroup axisLookXGain = new (newLabel: "Look Orbit X Gain");
|
||||
public FloatValueGroup axisLookYGain = new (newLabel: "Look Orbit Y Gain");
|
||||
|
||||
[ParadoxNotion.Design.Header("Rotation Composer Settings")]
|
||||
[ParadoxNotion.Design.Header("Rotation Composer Settings"), Space(8)]
|
||||
public Vector2ValueGroup screenPosition = new (newLabel: "Screen Position");
|
||||
|
||||
[ParadoxNotion.Design.Header("Camera Offset Settings")]
|
||||
[ParadoxNotion.Design.Header("Camera Offset Settings"), Space(8)]
|
||||
public Vector3ValueGroup cameraOffset = new (newLabel: "Offset");
|
||||
|
||||
private CameraSettingsProcessor processor;
|
||||
|
||||
//Use for initialization. This is called only once in the lifetime of the task.
|
||||
//Return null if init was successfull. Return an error string otherwise
|
||||
protected override string OnInit(){
|
||||
processor = CameraSettingsProcessor.Instance;
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -42,29 +46,28 @@ namespace NodeCanvas.Tasks.Actions {
|
||||
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||
//EndAction can be called from anywhere.
|
||||
protected override void OnExecute(){
|
||||
OrbitalFollowValueGroup.UpdateValue(orbitFollowTop, ref CameraSettingsProcessor.data.orbitFollowTopHeight.targetValue, ref CameraSettingsProcessor.original.orbitFollowTopRadius.targetValue);
|
||||
OrbitalFollowValueGroup.UpdateValue(orbitFollowCenter, ref CameraSettingsProcessor.data.orbitFollowCenterHeight.targetValue, ref CameraSettingsProcessor.original.orbitFollowCenterRadius.targetValue);
|
||||
OrbitalFollowValueGroup.UpdateValue(orbitFollowBottom, ref CameraSettingsProcessor.data.orbitFollowBottomHeight.targetValue, ref CameraSettingsProcessor.original.orbitFollowBottomRadius.targetValue);
|
||||
OrbitalFollowValueGroup.UpdateValue(orbitFollowTop, processor.data.orbitFollowTopHeight, processor.data.orbitFollowTopRadius);
|
||||
OrbitalFollowValueGroup.UpdateValue(orbitFollowCenter, processor.data.orbitFollowCenterHeight, processor.data.orbitFollowCenterRadius);
|
||||
OrbitalFollowValueGroup.UpdateValue(orbitFollowBottom, processor.data.orbitFollowBottomHeight, processor.data.orbitFollowBottomRadius);
|
||||
|
||||
Vector3ValueGroup.UpdateValue(cameraOffset, ref CameraSettingsProcessor.data.cameraOffsetOffset.targetValue, ref CameraSettingsProcessor.original.cameraOffsetOffset.targetValue);
|
||||
Vector3ValueGroup.UpdateValue(cameraOffset, processor.data.cameraOffsetOffset);
|
||||
|
||||
Vector3ValueGroup.UpdateValue(orbitPositionDamping, ref CameraSettingsProcessor.data.orbitPositionDamping.targetValue, ref CameraSettingsProcessor.original.cameraOffsetOffset.targetValue);
|
||||
Vector3ValueGroup.UpdateValue(orbitTargetOffset, ref CameraSettingsProcessor.data.orbitTargetOffset.targetValue, ref CameraSettingsProcessor.original.cameraOffsetOffset.targetValue);
|
||||
Vector3ValueGroup.UpdateValue(orbitPositionDamping, processor.data.orbitPositionDamping);
|
||||
Vector3ValueGroup.UpdateValue(orbitTargetOffset, processor.data.orbitTargetOffset);
|
||||
|
||||
Vector2ValueGroup.UpdateValue(screenPosition, ref CameraSettingsProcessor.data.rotationComposerScreenPos.targetValue, ref CameraSettingsProcessor.original.rotationComposerScreenPos.targetValue);
|
||||
FloatValueGroup.UpdateValue(fieldOfView, ref CameraSettingsProcessor.data.mainFieldOfView.targetValue, ref CameraSettingsProcessor.original.mainFieldOfView.targetValue);
|
||||
Vector2ValueGroup.UpdateValue(screenPosition, processor.data.rotationComposerScreenPos);
|
||||
|
||||
FloatValueGroup.UpdateValue(axisLookXGain, ref CameraSettingsProcessor.data.axisLookGainX.targetValue, ref CameraSettingsProcessor.original.axisLookGainX.targetValue);
|
||||
FloatValueGroup.UpdateValue(axisLookYGain, ref CameraSettingsProcessor.data.axisLookGainY.targetValue, ref CameraSettingsProcessor.original.axisLookGainY.targetValue);
|
||||
FloatValueGroup.UpdateValue(fieldOfView, processor.data.mainFieldOfView);
|
||||
|
||||
BoolValueGroup.UpdateValue(enableXAxis, ref CameraSettingsProcessor.data.axisLookEnabledX.targetValue, ref CameraSettingsProcessor.original.axisLookEnabledX.targetValue);
|
||||
BoolValueGroup.UpdateValue(enableYAxis, ref CameraSettingsProcessor.data.axisLookEnabledY.targetValue, ref CameraSettingsProcessor.original.axisLookEnabledY.targetValue);
|
||||
FloatValueGroup.UpdateValue(axisLookXGain, processor.data.axisLookGainX);
|
||||
FloatValueGroup.UpdateValue(axisLookYGain, processor.data.axisLookGainY);
|
||||
|
||||
BoolValueGroup.UpdateValue(enableXAxis, processor.data.axisLookEnabledX);
|
||||
BoolValueGroup.UpdateValue(enableYAxis, processor.data.axisLookEnabledY);
|
||||
|
||||
EndAction(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Called once per frame while the action is active.
|
||||
protected override void OnUpdate() {
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace NodeCanvas.Tasks.Actions {
|
||||
directionOnStart = agent.transform.position.DirectionTo(grapplePoint.value);
|
||||
|
||||
// Get the current move direction
|
||||
velocityOnStart = agent.outputMoveDirection;
|
||||
// velocityOnStart = agent.outputMoveDirection; // NOTE: Deprecated by new movement values
|
||||
|
||||
// For setting finalDirection's initial value, first compose the swing variables one-time
|
||||
Vector3 velocityWhenMoving = CalculateSwingDirections(Vector3.Distance(agent.transform.position, grapplePoint.value), directionOnStart);
|
||||
@@ -86,7 +86,7 @@ namespace NodeCanvas.Tasks.Actions {
|
||||
|
||||
//Called once per frame while the action is active.
|
||||
protected override void OnUpdate(){
|
||||
agent.outputMoveDirection = Vector3.MoveTowards(agent.outputMoveDirection, Vector3.zero, .5f);
|
||||
// agent.outputMoveDirection = Vector3.MoveTowards(agent.outputMoveDirection, Vector3.zero, .5f); // NOTE: Deprecated by new movement values
|
||||
|
||||
// Basic variables, direction to point and current distnace
|
||||
Vector3 directionToPoint = agent.transform.position.DirectionTo(grapplePoint.value);
|
||||
@@ -178,7 +178,7 @@ namespace NodeCanvas.Tasks.Actions {
|
||||
gizmoFinalDirection = finalDirection;
|
||||
|
||||
// Finalize the movement to the controller
|
||||
agent.SetNewDirection(Vector3.Lerp(agent.additionalMoveDirection, finalDirection.Flatten(null, 0), 1f * Time.deltaTime));
|
||||
// agent.SetNewDirection(Vector3.Lerp(agent.additionalMoveDirection, finalDirection.Flatten(null, 0), 1f * Time.deltaTime)); // NOTE: Deprecated by new movement values
|
||||
agent.SetNewGravity(finalDirection.y);
|
||||
agent.SmoothToSpeed(speed, 25f * Time.deltaTime);
|
||||
|
||||
|
||||
@@ -10,15 +10,9 @@ namespace Reset.Units {
|
||||
public class ChangeDirectionSettings : ActionTask<UnitMovementHandler> {
|
||||
// Direction
|
||||
[Space(5)]
|
||||
public Vector3ValueGroup feedNewDirection = new Vector3ValueGroup("Feed New Direction");
|
||||
public float newDirectionStrength;
|
||||
[Space(5)]
|
||||
public Vector2 addDirectionFromInput;
|
||||
public float addInputStrength;
|
||||
[SliderField(0,1)]
|
||||
public float addInputPriorty;
|
||||
|
||||
public FloatValueGroup directionSmoothing = new FloatValueGroup("Direction Smoothing");
|
||||
public FloatValueGroup directionChangingSoftness = new FloatValueGroup("Direction Changing Softness");
|
||||
public FloatValueGroup directionSpinningHardness = new FloatValueGroup("Direction Spinning Hardness");
|
||||
public FloatValueGroup directionSpinningSpeed = new FloatValueGroup("Direction Spinning Speed");
|
||||
|
||||
//Use for initialization. This is called only once in the lifetime of the task.
|
||||
//Return null if init was successfull. Return an error string otherwise
|
||||
@@ -30,23 +24,9 @@ namespace Reset.Units {
|
||||
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||
//EndAction can be called from anywhere.
|
||||
protected override void OnExecute() {
|
||||
// Direction from value
|
||||
// Check that feedDir is not changed
|
||||
// UpdateVector3Value(feedNewDirection, ref feedDir, ref feedDir);
|
||||
//
|
||||
// Vector3ValueGroup.ResolvedValue(feedNewDirection, ref feedDir, ref feedDir);
|
||||
//
|
||||
// // If there's a direciton add it to the player for a frame
|
||||
// if (feedDir != Vector3.zero) {
|
||||
// agent.AddToCurrentDirection(agent.transform.rotation * feedDir.normalized, newDirectionStrength);
|
||||
// // Reset the fed direction after it's added so future runs don't have
|
||||
// feedDir = Vector3.zero;
|
||||
// }
|
||||
|
||||
// Direction from controller input
|
||||
if (addDirectionFromInput != Vector2.zero){
|
||||
agent.OverwriteDirectionFromInput(new Vector3(addDirectionFromInput.x, addDirectionFromInput.y), addInputPriorty, addInputStrength);
|
||||
}
|
||||
FloatValueGroup.UpdateValue(directionChangingSoftness, agent.data.directionChangingSoftness);
|
||||
FloatValueGroup.UpdateValue(directionSpinningHardness, agent.data.directionSpinningHardness);
|
||||
FloatValueGroup.UpdateValue(directionSpinningSpeed, agent.data.directionSpinningSpeed);
|
||||
|
||||
EndAction(true);
|
||||
}
|
||||
|
||||
@@ -9,10 +9,8 @@ namespace Reset.Units {
|
||||
|
||||
[Category("Reset/Movement")]
|
||||
public class ChangeGravitySettings : ActionTask<UnitMovementHandler>{
|
||||
[SerializeField] public FloatValueGroup jumpPower = new FloatValueGroup("Jump Power");
|
||||
[SerializeField] public FloatValueGroup jumpPowerDecay = new FloatValueGroup("Jump Power Decay");
|
||||
[SliderField(0f, 1f), SerializeField] public FloatValueGroup airDirectionDecay = new FloatValueGroup("Air Direction Decay");
|
||||
|
||||
[SerializeField] public FloatValueGroup gravityPower = new FloatValueGroup("Gravity Power");
|
||||
[SerializeField] public FloatValueGroup gravityMax = new FloatValueGroup("Gravity Max");
|
||||
[SerializeField] public FloatValueGroup gravityAcceleration = new FloatValueGroup("Gravity Acceleration");
|
||||
[SerializeField] public FloatValueGroup gravityScale = new FloatValueGroup("Gravity Scale");
|
||||
@@ -27,23 +25,10 @@ namespace Reset.Units {
|
||||
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||
//EndAction can be called from anywhere.
|
||||
protected override void OnExecute() {
|
||||
// Deprecated by unified gravity system, including SetNewGravity
|
||||
// // Jump
|
||||
// FloatValueGroup.UpdateValue(jumpPower, ref agent.data.jumpPower.value, ref agent.defaultData.jumpPower.value);
|
||||
// ValueGroup.ChangeSmoothingEasing(jumpPower, ref agent.data.jumpPower.currentSmoothing,
|
||||
// ref agent.data.jumpPower.easing, ref agent.defaultData.jumpPower.smoothing, ref agent.defaultData.jumpPower.easing);
|
||||
|
||||
// FloatValueGroup.UpdateValue(jumpPowerDecay, agent.data.jumpPowerDecay);
|
||||
|
||||
// Deprecated by SetNewGravity
|
||||
// FloatValueGroup.UpdateValue(gravityPower, ref agent.data.gravityPower.value, ref agent.defaultData.gravityPower.value);
|
||||
// ValueGroup.ChangeSmoothingEasing(gravityPower, ref agent.data.gravityPower.currentSmoothing,
|
||||
// ref agent.data.gravityPower.easing, ref agent.defaultData.gravityPower.smoothing, ref agent.defaultData.gravityPower.easing);
|
||||
FloatValueGroup.UpdateValue(airDirectionDecay, agent.data.airDirectionDecay);
|
||||
|
||||
FloatValueGroup.UpdateValue(gravityMax, agent.data.gravityMax);
|
||||
|
||||
FloatValueGroup.UpdateValue(gravityAcceleration, agent.data.gravityAcceleration);
|
||||
|
||||
FloatValueGroup.UpdateValue(gravityScale, agent.data.gravityScale);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,18 +22,9 @@ namespace Reset.Units {
|
||||
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||
//EndAction can be called from anywhere.
|
||||
protected override void OnExecute() {
|
||||
FloatValueGroup.UpdateValue(moveSpeed, ref agent.data.moveSpeed.targetValue, ref agent.data.moveSpeed.defaultValue);
|
||||
ValueGroup.ChangeSmoothingEasing(moveSpeed, ref agent.data.moveSpeed.targetSmoothing,
|
||||
ref agent.data.moveSpeed.targetEasing, ref agent.data.moveSpeed.defaultSmoothing, ref agent.data.moveSpeed.defaultEasing);
|
||||
|
||||
FloatValueGroup.UpdateValue(acceleration, ref agent.data.acceleration.targetValue, ref agent.data.acceleration.defaultValue);
|
||||
ValueGroup.ChangeSmoothingEasing(acceleration, ref agent.data.acceleration.targetSmoothing,
|
||||
ref agent.data.acceleration.targetEasing, ref agent.data.acceleration.defaultSmoothing, ref agent.data.acceleration.defaultEasing);
|
||||
|
||||
FloatValueGroup.UpdateValue(deacceleration, ref agent.data.deacceleration.targetValue, ref agent.data.deacceleration.defaultValue);
|
||||
ValueGroup.ChangeSmoothingEasing(deacceleration, ref agent.data.deacceleration.targetSmoothing,
|
||||
ref agent.data.deacceleration.targetEasing, ref agent.data.deacceleration.defaultSmoothing, ref agent.data.deacceleration.defaultEasing);
|
||||
|
||||
FloatValueGroup.UpdateValue(moveSpeed, agent.data.moveSpeed);
|
||||
FloatValueGroup.UpdateValue(acceleration, agent.data.acceleration);
|
||||
FloatValueGroup.UpdateValue(deacceleration, agent.data.deacceleration);
|
||||
|
||||
EndAction(true);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
using System;
|
||||
using Codice.Client.BaseCommands;
|
||||
using NodeCanvas.Framework;
|
||||
using ParadoxNotion.Design;
|
||||
using Reset.Core;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace Reset.Units {
|
||||
|
||||
[Category("Reset/Movement")]
|
||||
public class ChangeRotationSettings : ActionTask<UnitMovementHandler> {
|
||||
|
||||
[SerializeField] public EnumValueGroup facingDirection = new EnumValueGroup("Facing Direction", PlayerFacingDirection.TowardsTarget);
|
||||
[SerializeField] public FloatValueGroup rotationSpeed = new (newLabel: "Rotation Speed");
|
||||
|
||||
//Use for initialization. This is called only once in the lifetime of the task.
|
||||
//Return null if init was successfull. Return an error string otherwise
|
||||
protected override string OnInit() {
|
||||
@@ -16,7 +22,10 @@ namespace Reset.Units {
|
||||
//This is called once each time the task is enabled.
|
||||
//Call EndAction() to mark the action as finished, either in success or failure.
|
||||
//EndAction can be called from anywhere.
|
||||
protected override void OnExecute() {
|
||||
protected override void OnExecute(){
|
||||
EnumValueGroup.UpdateValue(facingDirection, agent.data.facingDirection);
|
||||
FloatValueGroup.UpdateValue(rotationSpeed, agent.data.rotationSpeed);
|
||||
|
||||
EndAction(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace NodeCanvas.Tasks.Actions {
|
||||
switch (playerFacingDirection.value) {
|
||||
case PlayerFacingDirection.TowardsTarget:
|
||||
break;
|
||||
case PlayerFacingDirection.MatchForward: // TODO: Recomment
|
||||
case PlayerFacingDirection.MatchInput: // TODO: Recomment
|
||||
// targetDirection = agent.transform.forward * inputMovement.magnitude;
|
||||
targetDirection = inputMovement;
|
||||
break;
|
||||
|
||||
@@ -15,23 +15,23 @@ namespace Reset.Core{
|
||||
public BBParameter<float> Easing{ get; set; }
|
||||
}
|
||||
|
||||
public static void ChangeSmoothingEasing(ISmoothable valueGroup, ref float targetSmoothing,
|
||||
ref float targetEasing, ref float defaultSmoothing, ref float defaultEasing){
|
||||
public static void ChangeSmoothingEasing<T>(ISmoothable valueGroup, SettingValue<T> settingValue){
|
||||
switch (valueGroup.changeSmoothing.value) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetSmoothing = valueGroup.Smoothing.value;
|
||||
settingValue.targetSmoothing = valueGroup.Smoothing.value;
|
||||
settingValue.currentSmoothing = valueGroup.Smoothing.value;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetSmoothing = defaultSmoothing;
|
||||
settingValue.targetSmoothing = settingValue.defaultSmoothing;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (valueGroup.changeEasing.value) {
|
||||
case ValueChangeAction.NewValue:
|
||||
targetEasing = valueGroup.Easing.value;
|
||||
settingValue.targetEasing = valueGroup.Easing.value;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetEasing = defaultEasing;
|
||||
settingValue.targetEasing = settingValue.defaultEasing;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -96,12 +96,54 @@ namespace Reset.Core{
|
||||
|
||||
changeEasing = new BBParameter<ValueChangeAction>();
|
||||
Easing = new BBParameter<float>().value = 0f;
|
||||
}
|
||||
|
||||
public static void UpdateValue(OrbitalFollowValueGroup valueGroup, SettingValue<float> heightSetting, SettingValue<float> radiusSetting){
|
||||
switch (valueGroup.changeHeight.value) {
|
||||
case ValueChangeAction.NoChange: break;
|
||||
case ValueChangeAction.NewValue:
|
||||
heightSetting.Value = valueGroup.height.value;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
heightSetting.Value = heightSetting.defaultValue;
|
||||
break;
|
||||
case ValueChangeAction.RelativeValue:
|
||||
heightSetting.Value += valueGroup.height.value;
|
||||
break;
|
||||
default:
|
||||
Debug.LogError($"No value was changed for part of {valueGroup.label} because this ValueChangeAction was not supported.");
|
||||
break;
|
||||
}
|
||||
|
||||
switch (valueGroup.changeRadius.value) {
|
||||
case ValueChangeAction.NoChange: break;
|
||||
case ValueChangeAction.NewValue:
|
||||
radiusSetting.Value = valueGroup.radius.value;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
radiusSetting.Value = radiusSetting.defaultValue;
|
||||
break;
|
||||
case ValueChangeAction.RelativeValue:
|
||||
radiusSetting.Value += valueGroup.radius.value;
|
||||
break;
|
||||
default:
|
||||
Debug.LogError($"No value was changed for part of {valueGroup.label} because this ValueChangeAction was not supported.");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ValueGroup.ChangeSmoothingEasing(valueGroup, heightSetting);
|
||||
|
||||
|
||||
// Debug.Log($"{heightSetting.targetSmoothing} {valueGroup.Smoothing.value}");
|
||||
ValueGroup.ChangeSmoothingEasing(valueGroup, radiusSetting);
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public static void UpdateValue(OrbitalFollowValueGroup valueGroup, ref float targetProperty, ref float defaultProperty){
|
||||
switch (valueGroup.changeHeight.value) {
|
||||
case ValueChangeAction.NoChange: break;
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty = valueGroup.height.value;
|
||||
break;
|
||||
@@ -111,6 +153,7 @@ namespace Reset.Core{
|
||||
}
|
||||
|
||||
switch (valueGroup.changeRadius.value) {
|
||||
case ValueChangeAction.NoChange: break;
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty = valueGroup.radius.value;
|
||||
break;
|
||||
@@ -133,14 +176,18 @@ namespace Reset.Core{
|
||||
value = new AnimationCurve();
|
||||
label = newLabel;
|
||||
}
|
||||
|
||||
public static void UpdateValue(CurveValueGroup valueGroup, ref AnimationCurve targetProperty, ref AnimationCurve defaultProperty){
|
||||
|
||||
public static void UpdateValue(CurveValueGroup valueGroup, SettingValue<AnimationCurve> settingValue){
|
||||
switch (valueGroup.changeValue.value) {
|
||||
case ValueChangeAction.NoChange: break;
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty = valueGroup.value.value;
|
||||
settingValue.Value = valueGroup.value.value;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty = defaultProperty;
|
||||
settingValue.Value = settingValue.defaultValue;
|
||||
break;
|
||||
default:
|
||||
Debug.LogError($"No value was changed for part of {valueGroup.label} because this ValueChangeAction was not supported.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -159,16 +206,21 @@ namespace Reset.Core{
|
||||
label = newLabel;
|
||||
}
|
||||
|
||||
public static void UpdateValue(EnumValueGroup valueGroup, ref Enum targetProperty, ref Enum defaultProperty){
|
||||
public static void UpdateValue<T>(EnumValueGroup valueGroup, SettingValue<T> settingValue){
|
||||
switch (valueGroup.changeValue.value) {
|
||||
case ValueChangeAction.NoChange: break;
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty = valueGroup.value.value;
|
||||
settingValue.Value = (T)(object)valueGroup.value.value;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
targetProperty = defaultProperty;
|
||||
settingValue.Value = settingValue.defaultValue;
|
||||
break;
|
||||
default:
|
||||
Debug.LogError($"No value was changed for part of {valueGroup.label} because this ValueChangeAction was not supported.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class Vector3ValueGroup : ValueGroup.ISmoothable{ // Done
|
||||
@@ -227,8 +279,57 @@ namespace Reset.Core{
|
||||
|
||||
changeEasing = new BBParameter<ValueChangeAction>();
|
||||
Easing = new BBParameter<float>().value = 0f;
|
||||
|
||||
}
|
||||
|
||||
public static void UpdateValue(Vector3ValueGroup valueGroup, SettingValue<Vector3> settingValue){
|
||||
Vector3 newValue = settingValue.Value;
|
||||
|
||||
switch (valueGroup.changeX.value) {
|
||||
case ValueChangeAction.NoChange: break;
|
||||
case ValueChangeAction.NewValue:
|
||||
newValue.x = valueGroup.value.value.x;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
newValue.x = settingValue.defaultValue.x;
|
||||
break;
|
||||
default:
|
||||
Debug.LogError($"No value was changed for part of {valueGroup.label} because this ValueChangeAction was not supported.");
|
||||
break;
|
||||
}
|
||||
|
||||
switch (valueGroup.changeY.value) {
|
||||
case ValueChangeAction.NoChange: break;
|
||||
case ValueChangeAction.NewValue:
|
||||
newValue.y = valueGroup.value.value.y;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
newValue.y = settingValue.defaultValue.y;
|
||||
break;
|
||||
default:
|
||||
Debug.LogError($"No value was changed for part of {valueGroup.label} because this ValueChangeAction was not supported.");
|
||||
break;
|
||||
}
|
||||
|
||||
switch (valueGroup.changeZ.value) {
|
||||
case ValueChangeAction.NoChange: break;
|
||||
case ValueChangeAction.NewValue:
|
||||
newValue.z = valueGroup.value.value.z;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
newValue.z = settingValue.defaultValue.z;
|
||||
break;
|
||||
default:
|
||||
Debug.LogError($"No value was changed for part of {valueGroup.label} because this ValueChangeAction was not supported.");
|
||||
break;
|
||||
}
|
||||
|
||||
settingValue.Value = newValue;
|
||||
|
||||
ValueGroup.ChangeSmoothingEasing(valueGroup, settingValue);
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public static void UpdateValue(Vector3ValueGroup valueGroup, ref Vector3 targetProperty, ref Vector3 defaultProperty){
|
||||
switch (valueGroup.changeX.value) {
|
||||
case ValueChangeAction.NewValue:
|
||||
@@ -313,7 +414,42 @@ namespace Reset.Core{
|
||||
changeEasing = new BBParameter<ValueChangeAction>();
|
||||
Easing = new BBParameter<float>().value = 0f;
|
||||
}
|
||||
|
||||
public static void UpdateValue(Vector2ValueGroup valueGroup, SettingValue<Vector2> settingValue){
|
||||
Vector2 newValue = settingValue.Value;
|
||||
|
||||
switch (valueGroup.changeX.value) {
|
||||
case ValueChangeAction.NoChange: break;
|
||||
case ValueChangeAction.NewValue:
|
||||
newValue.x = valueGroup.value.value.x;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
newValue.x = settingValue.defaultValue.x;
|
||||
break;
|
||||
default:
|
||||
Debug.LogError($"No value was changed for part of {valueGroup.label} because this ValueChangeAction was not supported.");
|
||||
break;
|
||||
}
|
||||
|
||||
switch (valueGroup.changeY.value) {
|
||||
case ValueChangeAction.NoChange: break;
|
||||
case ValueChangeAction.NewValue:
|
||||
newValue.y = valueGroup.value.value.y;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
newValue.y = settingValue.defaultValue.y;
|
||||
break;
|
||||
default:
|
||||
Debug.LogError($"No value was changed for part of {valueGroup.label} because this ValueChangeAction was not supported.");
|
||||
break;
|
||||
}
|
||||
|
||||
settingValue.Value = newValue;
|
||||
|
||||
ValueGroup.ChangeSmoothingEasing(valueGroup, settingValue);
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public static void UpdateValue(Vector2ValueGroup valueGroup, ref Vector2 targetProperty, ref Vector2 defaultProperty){
|
||||
switch (valueGroup.changeX.value) {
|
||||
case ValueChangeAction.NewValue:
|
||||
@@ -386,6 +522,7 @@ namespace Reset.Core{
|
||||
|
||||
public static void UpdateValue(FloatValueGroup valueGroup, SettingValue<float> settingValue){
|
||||
switch (valueGroup.changeValue.value) {
|
||||
case ValueChangeAction.NoChange: break;
|
||||
case ValueChangeAction.NewValue:
|
||||
settingValue.Value = valueGroup.value.value;
|
||||
break;
|
||||
@@ -395,12 +532,15 @@ namespace Reset.Core{
|
||||
case ValueChangeAction.RelativeValue:
|
||||
settingValue.Value += valueGroup.value.value;
|
||||
break;
|
||||
default:
|
||||
Debug.LogError($"No value was changed for part of {valueGroup.label} because this ValueChangeAction was not supported.");
|
||||
break;
|
||||
}
|
||||
|
||||
ValueGroup.ChangeSmoothingEasing(valueGroup, ref settingValue.targetSmoothing,
|
||||
ref settingValue.targetEasing, ref settingValue.defaultEasing, ref settingValue.defaultSmoothing);
|
||||
ValueGroup.ChangeSmoothingEasing(valueGroup, settingValue);
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public static void UpdateValue(FloatValueGroup valueGroup, ref float targetProperty, ref float defaultProperty){
|
||||
Debug.LogWarning("Deprecated call of UpdateValue(). Use the new one with only two arguments!");
|
||||
switch (valueGroup.changeValue.value) {
|
||||
@@ -429,8 +569,25 @@ namespace Reset.Core{
|
||||
changeValue = ValueChangeAction.NoChange;
|
||||
}
|
||||
|
||||
public static void UpdateValue(BoolValueGroup valueGroup, SettingValue<bool> settingValue){
|
||||
switch (valueGroup.changeValue.value) {
|
||||
case ValueChangeAction.NoChange: break;
|
||||
case ValueChangeAction.NewValue:
|
||||
settingValue.Value = valueGroup.value.value;
|
||||
break;
|
||||
case ValueChangeAction.ResetValue:
|
||||
settingValue.Value = settingValue.defaultValue;
|
||||
break;
|
||||
default:
|
||||
Debug.LogError($"No value was changed for part of {valueGroup.label} because this ValueChangeAction was not supported.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public static void UpdateValue(BoolValueGroup valueGroup, ref bool targetProperty, ref bool defaultProperty){
|
||||
switch (valueGroup.changeValue.value) {
|
||||
case ValueChangeAction.NoChange: break;
|
||||
case ValueChangeAction.NewValue:
|
||||
targetProperty = valueGroup.value.value;
|
||||
break;
|
||||
|
||||
@@ -16,14 +16,10 @@ using UnityEngine;
|
||||
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.label, labelOptions);
|
||||
GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText);
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
// Create the x settings enum
|
||||
@@ -66,13 +62,9 @@ using UnityEngine;
|
||||
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.label, labelOptions);
|
||||
GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText);
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
// Create the x settings enum
|
||||
@@ -105,14 +97,11 @@ using UnityEngine;
|
||||
GUILayout.MinWidth(100.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.label, labelOptions);
|
||||
GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText);
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
// Create the x settings enum
|
||||
@@ -152,22 +141,9 @@ using UnityEngine;
|
||||
GUILayout.MinWidth(20.0f),
|
||||
GUILayout.ExpandWidth(true),
|
||||
};
|
||||
|
||||
GUILayoutOption[] labelOptions = new GUILayoutOption[]{
|
||||
GUILayout.Width(200.0f),
|
||||
};
|
||||
|
||||
GUIStyle titleText = new GUIStyle{
|
||||
fontSize = 12,
|
||||
fontStyle = FontStyle.Bold,
|
||||
padding = new RectOffset(8, 0, 3,0),
|
||||
normal ={
|
||||
textColor = Color.white
|
||||
}
|
||||
};
|
||||
|
||||
// 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.Label(_instance.label, titleText);
|
||||
GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText);
|
||||
|
||||
// End the label
|
||||
GUILayout.EndHorizontal();
|
||||
@@ -210,14 +186,10 @@ using UnityEngine;
|
||||
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.label, labelOptions);
|
||||
GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText);
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
// Create the x settings enum
|
||||
@@ -292,14 +264,10 @@ using UnityEngine;
|
||||
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.label, labelOptions);
|
||||
GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText);
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
// Create the x settings enum
|
||||
@@ -354,49 +322,73 @@ using UnityEngine;
|
||||
|
||||
// Set layout options for the label and the float fields
|
||||
GUILayoutOption[] floatOptions = new GUILayoutOption[] {
|
||||
GUILayout.Width(300.0f),
|
||||
GUILayout.MinWidth(20.0f),
|
||||
// GUILayout.Width(300.0f),
|
||||
// GUILayout.MinWidth(20.0f),
|
||||
GUILayout.ExpandWidth(true),
|
||||
};
|
||||
|
||||
GUILayoutOption[] labelOptions = new GUILayoutOption[]{
|
||||
GUILayout.Width(60.0f),
|
||||
};
|
||||
|
||||
// Start a Horiztonal Section
|
||||
// Add the label
|
||||
GUILayout.Label(_instance.label, ValueGroupEditorUtilities.titleText);
|
||||
|
||||
// Start the smoothing and easing section
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
// Add the left side label
|
||||
GUILayout.Label(_instance.label, labelOptions);
|
||||
|
||||
// Create the height settings enum
|
||||
_instance.changeHeight.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", _instance.changeHeight.value);
|
||||
|
||||
// Create the value/disabled information field
|
||||
if (_instance.changeHeight.value == ValueChangeAction.NewValue){
|
||||
_instance.height.value = EditorGUILayout.FloatField(_instance.height.value, floatOptions);
|
||||
|
||||
GUIStyle smallText= new GUIStyle{
|
||||
fontSize = 10,
|
||||
padding = new RectOffset(8, 0, 0,0),
|
||||
normal ={
|
||||
textColor = Color.gray + Color.gray / 2f
|
||||
}
|
||||
};
|
||||
|
||||
// Start the left side for height
|
||||
GUILayout.BeginVertical();
|
||||
|
||||
// Draw the label
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("Height", smallText);
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
// Height
|
||||
BBParameterEditor.ParameterField("", _instance.changeHeight);
|
||||
|
||||
if (_instance.changeHeight.value == ValueChangeAction.NewValue || _instance.changeHeight.value == ValueChangeAction.RelativeValue){
|
||||
// _instance.value = EditorGUILayout.FloatField(_instance.value, floatOptions);
|
||||
BBParameterEditor.ParameterField("", _instance.height);
|
||||
} else {
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.TextField(_instance.changeHeight.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
// It do what it do.
|
||||
GUILayout.Space(5);
|
||||
|
||||
// Create the radius settings enum
|
||||
_instance.changeRadius.value = (ValueChangeAction)EditorGUILayout.EnumPopup("", _instance.changeRadius.value);
|
||||
|
||||
// Create the value/disabled information field
|
||||
if (_instance.changeRadius.value == ValueChangeAction.NewValue){
|
||||
_instance.radius = EditorGUILayout.FloatField(_instance.radius.value, floatOptions);
|
||||
|
||||
// Close height
|
||||
GUILayout.EndVertical();
|
||||
|
||||
// Start the right for radius
|
||||
GUILayout.BeginVertical();
|
||||
|
||||
// Draw the label
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("Radius", smallText);
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
// Radius
|
||||
BBParameterEditor.ParameterField("", _instance.changeRadius);
|
||||
|
||||
if (_instance.changeRadius.value == ValueChangeAction.NewValue || _instance.changeRadius.value == ValueChangeAction.RelativeValue){
|
||||
// _instance.value = EditorGUILayout.FloatField(_instance.value, floatOptions);
|
||||
BBParameterEditor.ParameterField("", _instance.radius);
|
||||
} else {
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.TextField(_instance.changeRadius.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
// Close this line up
|
||||
|
||||
// Close easing
|
||||
GUILayout.EndVertical();
|
||||
|
||||
GUILayout.Space(8);
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
ValueGroupEditorUtilities.DrawEasingAndSmoothingSection(_instance);
|
||||
@@ -463,7 +455,7 @@ using UnityEngine;
|
||||
EditorGUILayout.TextField(_instance.changeSmoothing.value == ValueChangeAction.NoChange ? "Unchanged" : "Reset", floatOptions);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
|
||||
|
||||
// Close easing
|
||||
GUILayout.EndVertical();
|
||||
|
||||
@@ -477,5 +469,14 @@ using UnityEngine;
|
||||
GUILayout.MinWidth(20.0f),
|
||||
GUILayout.ExpandWidth(true),
|
||||
};
|
||||
|
||||
public static GUIStyle titleText = new GUIStyle{
|
||||
fontSize = 12,
|
||||
fontStyle = FontStyle.Bold,
|
||||
padding = new RectOffset(8, 0, 3,0),
|
||||
normal ={
|
||||
textColor = Color.white
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user