unityzgy/.svn/pristine/37/3761d6e5401648f48eb873822ec7c09ca8d3691d.svn-base
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

61 lines
2.4 KiB
Plaintext

using System;
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;
namespace UnityStandardAssets.Vehicles.Aeroplane
{
[RequireComponent(typeof (AeroplaneController))]
public class AeroplaneUserControl4Axis : MonoBehaviour
{
// these max angles are only used on mobile, due to the way pitch and roll input are handled
public float maxRollAngle = 80;
public float maxPitchAngle = 80;
// reference to the aeroplane that we're controlling
private AeroplaneController m_Aeroplane;
private float m_Throttle;
private bool m_AirBrakes;
private float m_Yaw;
private void Awake()
{
// Set up the reference to the aeroplane controller.
m_Aeroplane = GetComponent<AeroplaneController>();
}
private void FixedUpdate()
{
// Read input for the pitch, yaw, roll and throttle of the aeroplane.
float roll = CrossPlatformInputManager.GetAxis("Mouse X");
float pitch = CrossPlatformInputManager.GetAxis("Mouse Y");
m_AirBrakes = CrossPlatformInputManager.GetButton("Fire1");
m_Yaw = CrossPlatformInputManager.GetAxis("Horizontal");
m_Throttle = CrossPlatformInputManager.GetAxis("Vertical");
#if MOBILE_INPUT
AdjustInputForMobileControls(ref roll, ref pitch, ref m_Throttle);
#endif
// Pass the input to the aeroplane
m_Aeroplane.Move(roll, pitch, m_Yaw, m_Throttle, m_AirBrakes);
}
private void AdjustInputForMobileControls(ref float roll, ref float pitch, ref float throttle)
{
// because mobile tilt is used for roll and pitch, we help out by
// assuming that a centered level device means the user
// wants to fly straight and level!
// this means on mobile, the input represents the *desired* roll angle of the aeroplane,
// and the roll input is calculated to achieve that.
// whereas on non-mobile, the input directly controls the roll of the aeroplane.
float intendedRollAngle = roll*maxRollAngle*Mathf.Deg2Rad;
float intendedPitchAngle = pitch*maxPitchAngle*Mathf.Deg2Rad;
roll = Mathf.Clamp((intendedRollAngle - m_Aeroplane.RollAngle), -1, 1);
pitch = Mathf.Clamp((intendedPitchAngle - m_Aeroplane.PitchAngle), -1, 1);
}
}
}