unityzgy/Assets/ThirdPackages/VRPackage/VRTK/Scripts/Locomotion/ObjectControlActions/VRTK_RotateObjectControlAction.cs
ayuan9957 bf12e02276 feat: 多语言本地化系统 - 支持中/英/法/俄实时切换
- LocalizationManager: 新增翻译表(SetFormatted/SetDuration/LocalizeOperateMsg)
- LoginPanel: InputField placeholder本地化、字体颜色保持
- HistoryPanel: 用时数据本地化、placeholder本地化
- RecordDetailPanel: 操作详情消息本地化(LanguageChanged重建)
- AppraiseWindowBase: 评价等级本地化、操作消息重建
- EditorAppraiser: 所有评估消息改用InjectOperateMsgLocalized
- StudentOperateRecorder: 新增InjectOperateMsgLocalized方法
- LocalizationLanguageTestBar: 单例模式、ScreenSpaceOverlay筛选
- 字体切换时保留颜色和verticalOverflow
2026-07-16 10:05:59 +08:00

39 lines
1.9 KiB
C#

// Rotate Object Control Action|ObjectControlActions|25020
namespace VRTK
{
using UnityEngine;
/// <summary>
/// The Rotate Object Control Action script is used to rotate the controlled GameObject around the up vector when changing the axis.
/// </summary>
/// <remarks>
/// The effect is a smooth rotation to simulate turning.
/// </remarks>
/// <example>
/// `VRTK/Examples/017_CameraRig_TouchpadWalking` has a collection of walls and slopes that can be traversed by the user with the touchpad. There is also an area that can only be traversed if the user is crouching.
///
/// To enable the Rotate Object Control Action, ensure one of the `TouchpadControlOptions` children (located under the Controller script alias) has the `Rotate` control script active.
/// </example>
[AddComponentMenu("VRTK/Scripts/Locomotion/Object Control Actions/VRTK_RotateObjectControlAction")]
public class VRTK_RotateObjectControlAction : VRTK_BaseObjectControlAction
{
[Tooltip("The maximum speed the controlled object can be rotated based on the position of the axis.")]
public float maximumRotationSpeed = 3f;
[Tooltip("The rotation multiplier to be applied when the modifier button is pressed.")]
public float rotationMultiplier = 1.5f;
protected override void Process(GameObject controlledGameObject, Transform directionDevice, Vector3 axisDirection, float axis, float deadzone, bool currentlyFalling, bool modifierActive)
{
float angle = Rotate(axis, modifierActive);
if (angle != 0f)
{
RotateAroundPlayer(controlledGameObject, angle);
}
}
protected virtual float Rotate(float axis, bool modifierActive)
{
return axis * maximumRotationSpeed * Time.deltaTime * (modifierActive ? rotationMultiplier : 1) * 10;
}
}
}