- LocalizationManager: 新增翻译表(SetFormatted/SetDuration/LocalizeOperateMsg) - LoginPanel: InputField placeholder本地化、字体颜色保持 - HistoryPanel: 用时数据本地化、placeholder本地化 - RecordDetailPanel: 操作详情消息本地化(LanguageChanged重建) - AppraiseWindowBase: 评价等级本地化、操作消息重建 - EditorAppraiser: 所有评估消息改用InjectOperateMsgLocalized - StudentOperateRecorder: 新增InjectOperateMsgLocalized方法 - LocalizationLanguageTestBar: 单例模式、ScreenSpaceOverlay筛选 - 字体切换时保留颜色和verticalOverflow
73 lines
2.5 KiB
Plaintext
73 lines
2.5 KiB
Plaintext
// Hip Tracking|Presence|70050
|
|
namespace VRTK
|
|
{
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// Hip Tracking attempts to reasonably track hip position in the absence of a hip position sensor.
|
|
/// </summary>
|
|
/// <remarks>
|
|
/// The Hip Tracking script is placed on an empty GameObject which will be positioned at the estimated hip position.
|
|
/// </remarks>
|
|
|
|
[AddComponentMenu("VRTK/Scripts/Presence/VRTK_HipTracking")]
|
|
public class VRTK_HipTracking : MonoBehaviour
|
|
{
|
|
[Tooltip("Distance underneath Player Head for hips to reside.")]
|
|
public float HeadOffset = -0.35f;
|
|
|
|
[Header("Optional")]
|
|
[Tooltip("Optional Transform to use as the Head Object for calculating hip position. If none is given one will try to be found in the scene.")]
|
|
public Transform headOverride;
|
|
[Tooltip("Optional Transform to use for calculating which way is 'Up' relative to the player for hip positioning.")]
|
|
public Transform ReferenceUp;
|
|
|
|
protected Transform playerHead;
|
|
|
|
protected virtual void Awake()
|
|
{
|
|
VRTK_SDKManager.instance.AddBehaviourToToggleOnLoadedSetupChange(this);
|
|
}
|
|
|
|
protected virtual void OnEnable()
|
|
{
|
|
playerHead = (headOverride != null ? headOverride : VRTK_DeviceFinder.HeadsetTransform());
|
|
}
|
|
|
|
protected virtual void OnDestroy()
|
|
{
|
|
VRTK_SDKManager.instance.RemoveBehaviourToToggleOnLoadedSetupChange(this);
|
|
}
|
|
|
|
protected virtual void LateUpdate()
|
|
{
|
|
if (playerHead == null)
|
|
{
|
|
return;
|
|
}
|
|
Vector3 up = Vector3.up;
|
|
if (ReferenceUp != null)
|
|
{
|
|
up = ReferenceUp.up;
|
|
}
|
|
|
|
transform.position = playerHead.position + (HeadOffset * up);
|
|
|
|
Vector3 forward = playerHead.forward;
|
|
Vector3 forwardLeveld1 = forward;
|
|
forwardLeveld1.y = 0;
|
|
forwardLeveld1.Normalize();
|
|
Vector3 mixedInLocalForward = playerHead.up;
|
|
if (forward.y > 0)
|
|
{
|
|
mixedInLocalForward = -playerHead.up;
|
|
}
|
|
mixedInLocalForward.y = 0;
|
|
mixedInLocalForward.Normalize();
|
|
|
|
float dot = Mathf.Clamp(Vector3.Dot(forwardLeveld1, forward), 0f, 1f);
|
|
Vector3 finalForward = Vector3.Lerp(mixedInLocalForward, forwardLeveld1, dot * dot);
|
|
transform.rotation = Quaternion.LookRotation(finalForward, up);
|
|
}
|
|
}
|
|
} |