public void UpdateAxis(float realValue, bool isOnDrag, ETCBase.ControlType type, bool deltaTime = true) { // Auto stabilization if (isAutoStab && axisValue == 0) { DoAutoStabilisation(); } if (invertedAxis) { realValue *= -1; } // Time push if (isValueOverTime && realValue != 0) { axisValue += overTimeStep * Mathf.Sign(realValue) * Time.deltaTime; if (Mathf.Sign(axisValue) > 0) { axisValue = Mathf.Clamp(axisValue, 0, maxOverTimeValue); } else { axisValue = Mathf.Clamp(axisValue, -maxOverTimeValue, 0); } } // Axis value ComputAxisValue(realValue, type, isOnDrag, deltaTime); }
// Token: 0x060004A6 RID: 1190 RVA: 0x00015850 File Offset: 0x00013C50 public void UpdateAxis(float realValue, bool isOnDrag, ETCBase.ControlType type, bool deltaTime = true) { if ((this.autoLinkTagPlayer && this.player == null) || (this.player && !this.player.activeSelf)) { this.player = GameObject.FindGameObjectWithTag(this.autoTag); if (this.player) { this.directTransform = this.player.transform; } } if (this.isAutoStab && this.axisValue == 0f && this._directTransform) { this.DoAutoStabilisation(); } if (this.invertedAxis) { realValue *= -1f; } if (this.isValueOverTime && realValue != 0f) { this.axisValue += this.overTimeStep * Mathf.Sign(realValue) * Time.deltaTime; if (Mathf.Sign(this.axisValue) > 0f) { this.axisValue = Mathf.Clamp(this.axisValue, 0f, this.maxOverTimeValue); } else { this.axisValue = Mathf.Clamp(this.axisValue, -this.maxOverTimeValue, 0f); } } this.ComputAxisValue(realValue, type, isOnDrag, deltaTime); }
private void ComputAxisValue(float realValue, ETCBase.ControlType type, bool isOnDrag, bool deltaTime) { if (enable) { if (type == ETCBase.ControlType.Joystick) { if (valueMethod == AxisValueMethod.Classical) { float dist = Mathf.Max(Mathf.Abs(realValue), 0.001f); float dead = Mathf.Max(dist - deadValue, 0) / (1f - deadValue) / dist; realValue *= dead; } else { //realValue = deadCurve.Evaluate( Mathf.Abs(realValue)) * Mathf.Sign( realValue); realValue = curveValue.Evaluate(realValue); } } if (isEnertia) { realValue = (realValue - axisValue); realValue /= inertia; axisValue += realValue; if (Mathf.Abs(axisValue) < inertiaThreshold && !isOnDrag) { axisValue = 0; } } else if (!isValueOverTime || (isValueOverTime && realValue == 0)) { axisValue = realValue; } if (deltaTime) { axisSpeedValue = axisValue * speed * BaseScene.GetDtTime(); } else { axisSpeedValue = axisValue * speed; } } else { axisValue = 0; axisSpeedValue = 0; } }
// Token: 0x060004AB RID: 1195 RVA: 0x00016030 File Offset: 0x00014430 private void ComputAxisValue(float realValue, ETCBase.ControlType type, bool isOnDrag, bool deltaTime) { if (this.enable) { if (type == ETCBase.ControlType.Joystick) { if (this.valueMethod == ETCAxis.AxisValueMethod.Classical) { float num = Mathf.Max(Mathf.Abs(realValue), 0.001f); float num2 = Mathf.Max(num - this.deadValue, 0f) / (1f - this.deadValue) / num; realValue *= num2; } else { realValue = this.curveValue.Evaluate(Mathf.Abs(realValue)) * Mathf.Sign(realValue); } } if (this.isEnertia) { realValue -= this.axisValue; realValue /= this.inertia; this.axisValue += realValue; if (Mathf.Abs(this.axisValue) < this.inertiaThreshold && !isOnDrag) { this.axisValue = 0f; } } else if (!this.isValueOverTime || (this.isValueOverTime && realValue == 0f)) { this.axisValue = realValue; } if (deltaTime) { this.axisSpeedValue = this.axisValue * this.speed * Time.deltaTime; } else { this.axisSpeedValue = this.axisValue * this.speed; } } else { this.axisValue = 0f; this.axisSpeedValue = 0f; } }
private void ComputAxisValue(float realValue, ETCBase.ControlType type, bool isOnDrag, bool deltaTime) { if (enable) { if (type == ETCBase.ControlType.Joystick) { float dist = Mathf.Max(Mathf.Abs(realValue), 0.001f); float dead = Mathf.Max(dist - deadValue, 0) / (1f - deadValue) / dist; realValue *= dead; } if (isEnertia) { realValue = (realValue - axisValue); realValue /= inertia; axisValue += realValue; if (Mathf.Abs(axisValue) < inertiaThreshold && !isOnDrag) { axisValue = 0; } } else if (!isValueOverTime || (isValueOverTime && realValue == 0)) { axisValue = realValue; } if (deltaTime) { axisSpeedValue = axisValue * speed * Time.deltaTime; } else { axisSpeedValue = axisValue * speed; } } else { axisValue = 0; axisSpeedValue = 0; } }
public void UpdateAxis(float realValue, bool isOnDrag, ETCBase.ControlType type, bool deltaTime = true) { // Auto link if (autoLinkTagPlayer && player == null || (player && !player.activeSelf)) { player = GameObject.FindGameObjectWithTag(autoTag); if (player) { directTransform = player.transform; } } // Auto stabilization if (isAutoStab && axisValue == 0 && _directTransform) { DoAutoStabilisation(); } if (invertedAxis) { realValue *= -1; } // Time push if (isValueOverTime && realValue != 0) { axisValue += overTimeStep * Mathf.Sign(realValue) * BaseScene.GetDtTime(); if (Mathf.Sign(axisValue) > 0) { axisValue = Mathf.Clamp(axisValue, 0, maxOverTimeValue); } else { axisValue = Mathf.Clamp(axisValue, -maxOverTimeValue, 0); } } // Axis value ComputAxisValue(realValue, type, isOnDrag, deltaTime); }
public static void AxisInspector(ETCAxis axis, string label, ETCBase.ControlType type, bool turnMove = false, string[] unityAxes = null) { EditorGUILayout.BeginHorizontal(); //GUI.color = color; axis.enable = ETCGuiTools.Toggle(label + " axis : ", axis.enable, true, 125, true); //GUI.color = Color.white; axis.name = EditorGUILayout.TextField("", axis.name, GUILayout.MinWidth(50)); EditorGUILayout.EndHorizontal(); if (axis.enable) { EditorGUI.indentLevel++; #region General //EditorGUILayout.LabelField( "General",EditorStyles.boldLabel); axis.showGeneralInspector = EditorGUILayout.Foldout(axis.showGeneralInspector, "General setting"); if (axis.showGeneralInspector) { ETCGuiTools.BeginGroup(20); { EditorGUI.indentLevel--; axis.actionOn = (ETCAxis.ActionOn)EditorGUILayout.EnumPopup("React on", axis.actionOn); EditorGUILayout.Space(); if (type == ETCBase.ControlType.Joystick) { axis.valueMethod = (ETCAxis.AxisValueMethod)EditorGUILayout.EnumPopup("Dead zone method", axis.valueMethod); switch (axis.valueMethod) { case ETCAxis.AxisValueMethod.Classical: axis.deadValue = EditorGUILayout.Slider("Dead length", axis.deadValue, 0f, 1f); break; case ETCAxis.AxisValueMethod.Curve: if (axis.curveValue == null) { axis.InitDeadCurve(); } axis.curveValue = EditorGUILayout.CurveField("Sensitivity curve", axis.curveValue); break; } } EditorGUILayout.Space(); axis.invertedAxis = ETCGuiTools.Toggle("Inverted axis", axis.invertedAxis, true); EditorGUILayout.Space(); #region Button & DPAD Value over the time if (type == ETCBase.ControlType.Button || type == ETCBase.ControlType.DPad) { axis.isValueOverTime = ETCGuiTools.Toggle("Value over the time", axis.isValueOverTime, true); if (axis.isValueOverTime) { //EditorGUI.indentLevel--; ETCGuiTools.BeginGroup(5); { axis.overTimeStep = EditorGUILayout.FloatField("Step", axis.overTimeStep); axis.maxOverTimeValue = EditorGUILayout.FloatField("Max value", axis.maxOverTimeValue); } ETCGuiTools.EndGroup(); //EditorGUI.indentLevel++; } } #endregion #region Joysick if (type == ETCBase.ControlType.Joystick) { axis.axisThreshold = EditorGUILayout.Slider("On/Off Threshold", axis.axisThreshold, 0f, 1f); } #endregion if (!turnMove) { string labelspeed = "Speed"; if (type == ETCBase.ControlType.TouchPad) { labelspeed = "Sensitivity"; } axis.speed = EditorGUILayout.FloatField(labelspeed, axis.speed); } EditorGUI.indentLevel++; } ETCGuiTools.EndGroup(); } #endregion if (!turnMove) { #region Direction Action axis.showDirectInspector = EditorGUILayout.Foldout(axis.showDirectInspector, "Direction ation (optional)"); if (axis.showDirectInspector) { ETCGuiTools.BeginGroup(20); { EditorGUI.indentLevel--; //EditorGUILayout.BeginHorizontal(); axis.autoLinkTagPlayer = EditorGUILayout.ToggleLeft("Auto link on tag", axis.autoLinkTagPlayer, GUILayout.Width(200)); if (axis.autoLinkTagPlayer) { axis.autoTag = EditorGUILayout.TagField("", axis.autoTag); } //EditorGUILayout.EndHorizontal(); if (!axis.autoLinkTagPlayer) { axis.directTransform = (Transform)EditorGUILayout.ObjectField("Direct action to", axis.directTransform, typeof(Transform), true); } axis.directAction = (ETCAxis.DirectAction)EditorGUILayout.EnumPopup("Action", axis.directAction); if (axis.directAction != ETCAxis.DirectAction.Jump) { axis.axisInfluenced = (ETCAxis.AxisInfluenced)EditorGUILayout.EnumPopup("Affected axis", axis.axisInfluenced); } else { EditorGUILayout.HelpBox("Required character controller", MessageType.Info); } if ((axis.directCharacterController || axis.autoLinkTagPlayer) && (axis.directAction == ETCAxis.DirectAction.Translate || axis.directAction == ETCAxis.DirectAction.TranslateLocal)) { axis.isLockinJump = EditorGUILayout.Toggle("Lock in jump", axis.isLockinJump); if (axis.autoLinkTagPlayer) { EditorGUILayout.HelpBox("Required character controller", MessageType.Info); } } EditorGUI.indentLevel++; } ETCGuiTools.EndGroup(); } #endregion #region smooth & inertia axis.showInertiaInspector = EditorGUILayout.Foldout(axis.showInertiaInspector, "Gravity-Inertia-smoothing..."); if (axis.showInertiaInspector) { ETCGuiTools.BeginGroup(20); { EditorGUI.indentLevel--; if (axis.directCharacterController != null || axis.autoLinkTagPlayer) { axis.gravity = EditorGUILayout.FloatField("Gravity", axis.gravity); } // Inertia axis.isEnertia = ETCGuiTools.Toggle("Enable inertia", axis.isEnertia, true); if (axis.isEnertia) { //EditorGUI.indentLevel--; ETCGuiTools.BeginGroup(5); { axis.inertia = EditorGUILayout.Slider("Inertia", axis.inertia, 1f, 500f); axis.inertiaThreshold = EditorGUILayout.FloatField("Threshold", axis.inertiaThreshold); } ETCGuiTools.EndGroup(); //EditorGUI.indentLevel++; } // AutoStab & clamp rotation if (axis.directAction == ETCAxis.DirectAction.RotateLocal) { //AutoStab axis.isAutoStab = ETCGuiTools.Toggle("Automatic stabilization", axis.isAutoStab, true); if (axis.isAutoStab) { //EditorGUI.indentLevel--; ETCGuiTools.BeginGroup(5); { axis.autoStabSpeed = EditorGUILayout.FloatField("Speed", axis.autoStabSpeed); axis.autoStabThreshold = EditorGUILayout.FloatField("Threshold ", axis.autoStabThreshold); } ETCGuiTools.EndGroup(); //EditorGUI.indentLevel++; } // clamp rotation axis.isClampRotation = ETCGuiTools.Toggle("Clamp rotation", axis.isClampRotation, true); if (axis.isClampRotation) { //EditorGUI.indentLevel--; ETCGuiTools.BeginGroup(5); { axis.maxAngle = EditorGUILayout.FloatField("Max angle", axis.maxAngle); axis.minAngle = EditorGUILayout.FloatField("Min angle", axis.minAngle); } ETCGuiTools.EndGroup(); //EditorGUI.indentLevel++; } } EditorGUI.indentLevel++; } ETCGuiTools.EndGroup(); } #endregion } #region Unity axes axis.showSimulatinInspector = EditorGUILayout.Foldout(axis.showSimulatinInspector, "Unity axes"); if (axis.showSimulatinInspector) { ETCGuiTools.BeginGroup(20); { EditorGUI.indentLevel--; int index = System.Array.IndexOf(unityAxes, axis.unityAxis); int tmpIndex = EditorGUILayout.Popup(index, unityAxes); if (tmpIndex != index) { axis.unityAxis = unityAxes[tmpIndex]; } EditorGUI.indentLevel++; } ETCGuiTools.EndGroup(); } #endregion EditorGUI.indentLevel--; } }
public static void AxisInspector(ETCAxis axis, string label, ETCBase.ControlType type) { EditorGUILayout.BeginHorizontal(); //GUI.color = color; axis.enable = ETCGuiTools.Toggle(label + " axis : ", axis.enable, true, 125, true); //GUI.color = Color.white; axis.name = EditorGUILayout.TextField("", axis.name, GUILayout.MinWidth(50)); EditorGUILayout.EndHorizontal(); if (axis.enable) { EditorGUI.indentLevel++; axis.invertedAxis = ETCGuiTools.Toggle("Inverted axis", axis.invertedAxis, true); if (type == ETCBase.ControlType.Joystick) { axis.deadValue = EditorGUILayout.Slider("Dead lenght", axis.deadValue, 0f, 1f); } if (type == ETCBase.ControlType.Button || type == ETCBase.ControlType.DPad) { axis.isValueOverTime = ETCGuiTools.Toggle("Value over the time", axis.isValueOverTime, true); if (axis.isValueOverTime) { //EditorGUI.indentLevel--; ETCGuiTools.BeginGroup(5); { axis.overTimeStep = EditorGUILayout.FloatField("Step", axis.overTimeStep); axis.maxOverTimeValue = EditorGUILayout.FloatField("Max value", axis.maxOverTimeValue); } ETCGuiTools.EndGroup(); //EditorGUI.indentLevel++; } } if (type == ETCBase.ControlType.Joystick) { axis.axisThreshold = EditorGUILayout.Slider("On/Off Threshold", axis.axisThreshold, 0f, 1f); } string labelspeed = "Speed"; if (type == ETCBase.ControlType.TouchPad) { labelspeed = "Sensitivity"; } axis.speed = EditorGUILayout.FloatField(labelspeed, axis.speed); // Direct properties EditorGUILayout.Space(); axis.actionOn = (ETCAxis.ActionOn)EditorGUILayout.EnumPopup("Action on", axis.actionOn); axis.directTransform = (Transform)EditorGUILayout.ObjectField("Direct action to", axis.directTransform, typeof(Transform), true); axis.directAction = (ETCAxis.DirectAction)EditorGUILayout.EnumPopup("Action", axis.directAction); axis.axisInfluenced = (ETCAxis.AxisInfluenced)EditorGUILayout.EnumPopup("Affected axis", axis.axisInfluenced); EditorGUILayout.Space(); if (axis.directCharacterController != null) { axis.gravity = EditorGUILayout.FloatField("Gravity", axis.gravity); } //if (type != ETCBase.ControlType.TouchPad){ // Inertia axis.isEnertia = ETCGuiTools.Toggle("Enable inertia", axis.isEnertia, true); if (axis.isEnertia) { EditorGUI.indentLevel--; ETCGuiTools.BeginGroup(20); { axis.inertia = EditorGUILayout.Slider("Inertia", axis.inertia, 1f, 500f); axis.inertiaThreshold = EditorGUILayout.FloatField("Threshold", axis.inertiaThreshold); } ETCGuiTools.EndGroup(); EditorGUI.indentLevel++; } // AutoStab & clamp rotation if (axis.directAction == ETCAxis.DirectAction.RotateLocal) { //AutoStab axis.isAutoStab = ETCGuiTools.Toggle("Automatic stabilization", axis.isAutoStab, true); if (axis.isAutoStab) { EditorGUI.indentLevel--; ETCGuiTools.BeginGroup(20); { axis.autoStabSpeed = EditorGUILayout.FloatField("Speed", axis.autoStabSpeed); axis.autoStabThreshold = EditorGUILayout.FloatField("Threshold ", axis.autoStabThreshold); } ETCGuiTools.EndGroup(); EditorGUI.indentLevel++; } // clamp rotation axis.isClampRotation = ETCGuiTools.Toggle("Clamp rotation", axis.isClampRotation, true); if (axis.isClampRotation) { EditorGUI.indentLevel--; ETCGuiTools.BeginGroup(20); { axis.maxAngle = EditorGUILayout.FloatField("Max angle", axis.maxAngle); axis.minAngle = EditorGUILayout.FloatField("Min angle", axis.minAngle); } ETCGuiTools.EndGroup(); EditorGUI.indentLevel++; } } //} EditorGUILayout.Space(); axis.positivekey = (UnityEngine.KeyCode)EditorGUILayout.EnumPopup("Positive key", axis.positivekey); axis.negativeKey = (UnityEngine.KeyCode)EditorGUILayout.EnumPopup("Negative key", axis.negativeKey); EditorGUI.indentLevel--; } }