unityzgy/.svn/pristine/4b/4bd6ff262a24a9ce28e6201fc227581018374afe.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

68 lines
3.4 KiB
Plaintext

// Headset Collision Fade|Presence|70030
namespace VRTK
{
using UnityEngine;
/// <summary>
/// The purpose of the Headset Collision Fade is to detect when the user's VR headset collides with another game object and fades the screen to a solid colour.
/// </summary>
/// <remarks>
/// This is to deal with a user putting their head into a game object and seeing the inside of the object clipping, which is an undesired effect. The reasoning behind this is if the user puts their head where it shouldn't be, then fading to a colour (e.g. black) will make the user realise they've done something wrong and they'll probably naturally step backwards.
///
/// The Headset Collision Fade uses a composition of the Headset Collision and Headset Fade scripts to derive the desired behaviour.
/// </remarks>
/// <example>
/// `VRTK/Examples/011_Camera_HeadSetCollisionFading` has collidable walls around the play area and if the user puts their head into any of the walls then the headset will fade to black.
/// </example>
[RequireComponent(typeof(VRTK_HeadsetCollision)), RequireComponent(typeof(VRTK_HeadsetFade))]
[AddComponentMenu("VRTK/Scripts/Presence/VRTK_HeadsetCollisionFade")]
public class VRTK_HeadsetCollisionFade : MonoBehaviour
{
[Header("Collision Fade Settings")]
[Tooltip("The amount of time to wait until a fade occurs.")]
public float timeTillFade = 0f;
[Tooltip("The fade blink speed on collision.")]
public float blinkTransitionSpeed = 0.1f;
[Tooltip("The colour to fade the headset to on collision.")]
public Color fadeColor = Color.black;
[Header("Custom Settings")]
[Tooltip("The VRTK Headset Collision script to use when determining headset collisions. If this is left blank then the script will need to be applied to the same GameObject.")]
public VRTK_HeadsetCollision headsetCollision;
[Tooltip("The VRTK Headset Fade script to use when fading the headset. If this is left blank then the script will need to be applied to the same GameObject.")]
public VRTK_HeadsetFade headsetFade;
protected virtual void OnEnable()
{
headsetFade = (headsetFade != null ? headsetFade : GetComponentInChildren<VRTK_HeadsetFade>());
headsetCollision = (headsetCollision != null ? headsetCollision : GetComponentInChildren<VRTK_HeadsetCollision>());
headsetCollision.HeadsetCollisionDetect += new HeadsetCollisionEventHandler(OnHeadsetCollisionDetect);
headsetCollision.HeadsetCollisionEnded += new HeadsetCollisionEventHandler(OnHeadsetCollisionEnded);
}
protected virtual void OnDisable()
{
headsetCollision.HeadsetCollisionDetect -= new HeadsetCollisionEventHandler(OnHeadsetCollisionDetect);
headsetCollision.HeadsetCollisionEnded -= new HeadsetCollisionEventHandler(OnHeadsetCollisionEnded);
}
protected virtual void OnHeadsetCollisionDetect(object sender, HeadsetCollisionEventArgs e)
{
Invoke("StartFade", timeTillFade);
}
protected virtual void OnHeadsetCollisionEnded(object sender, HeadsetCollisionEventArgs e)
{
CancelInvoke("StartFade");
headsetFade.Unfade(blinkTransitionSpeed);
}
protected virtual void StartFade()
{
headsetFade.Fade(fadeColor, blinkTransitionSpeed);
}
}
}