unityzgy/Assets/ThirdPackages/VRPackage/SteamVR/InteractionSystem/Teleport/Scripts/ChaperoneInfo.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

88 lines
2.5 KiB
C#

//======= Copyright (c) Valve Corporation, All rights reserved. ===============
//
// Purpose: Stores the play area size info from the players chaperone data
//
//=============================================================================
using UnityEngine;
using UnityEngine.Events;
using System.Collections;
namespace Valve.VR.InteractionSystem
{
//-------------------------------------------------------------------------
public class ChaperoneInfo : MonoBehaviour
{
public bool initialized { get; private set; }
public float playAreaSizeX { get; private set; }
public float playAreaSizeZ { get; private set; }
public bool roomscale { get; private set; }
public static SteamVR_Events.Event Initialized = new SteamVR_Events.Event();
public static SteamVR_Events.Action InitializedAction( UnityAction action ) { return new SteamVR_Events.ActionNoArgs( Initialized, action ); }
//-------------------------------------------------
private static ChaperoneInfo _instance;
public static ChaperoneInfo instance
{
get
{
if ( _instance == null )
{
_instance = new GameObject( "[ChaperoneInfo]" ).AddComponent<ChaperoneInfo>();
_instance.initialized = false;
_instance.playAreaSizeX = 1.0f;
_instance.playAreaSizeZ = 1.0f;
_instance.roomscale = false;
DontDestroyOnLoad( _instance.gameObject );
}
return _instance;
}
}
//-------------------------------------------------
IEnumerator Start()
{
// Uncomment for roomscale testing
//_instance.initialized = true;
//_instance.playAreaSizeX = UnityEngine.Random.Range( 1.0f, 4.0f );
//_instance.playAreaSizeZ = UnityEngine.Random.Range( 1.0f, _instance.playAreaSizeX );
//_instance.roomscale = true;
//ChaperoneInfo.Initialized.Send();
//yield break;
// Get interface pointer
var chaperone = OpenVR.Chaperone;
if ( chaperone == null )
{
Debug.LogWarning( "Failed to get IVRChaperone interface." );
initialized = true;
yield break;
}
// Get play area size
while ( true )
{
float px = 0.0f, pz = 0.0f;
if ( chaperone.GetPlayAreaSize( ref px, ref pz ) )
{
initialized = true;
playAreaSizeX = px;
playAreaSizeZ = pz;
roomscale = Mathf.Max( px, pz ) > 1.01f;
Debug.LogFormat( "ChaperoneInfo initialized. {2} play area {0:0.00}m x {1:0.00}m", px, pz, roomscale ? "Roomscale" : "Standing" );
ChaperoneInfo.Initialized.Send();
yield break;
}
yield return null;
}
}
}
}