unityzgy/.svn/pristine/83/8332020335fcbbb6871ed4c7d2ae85e99ec74608.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

198 lines
4.3 KiB
Plaintext

//======= Copyright (c) Valve Corporation, All rights reserved. ===============
//
// Purpose: An area that the player can teleport to
//
//=============================================================================
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace Valve.VR.InteractionSystem
{
//-------------------------------------------------------------------------
public class TeleportArea : TeleportMarkerBase
{
//Public properties
public Bounds meshBounds { get; private set; }
//Private data
private MeshRenderer areaMesh;
private int tintColorId = 0;
private Color visibleTintColor = Color.clear;
private Color highlightedTintColor = Color.clear;
private Color lockedTintColor = Color.clear;
private bool highlighted = false;
//-------------------------------------------------
public void Awake()
{
areaMesh = GetComponent<MeshRenderer>();
tintColorId = Shader.PropertyToID( "_TintColor" );
CalculateBounds();
}
//-------------------------------------------------
public void Start()
{
visibleTintColor = Teleport.instance.areaVisibleMaterial.GetColor( tintColorId );
highlightedTintColor = Teleport.instance.areaHighlightedMaterial.GetColor( tintColorId );
lockedTintColor = Teleport.instance.areaLockedMaterial.GetColor( tintColorId );
}
//-------------------------------------------------
public override bool ShouldActivate( Vector3 playerPosition )
{
return true;
}
//-------------------------------------------------
public override bool ShouldMovePlayer()
{
return true;
}
//-------------------------------------------------
public override void Highlight( bool highlight )
{
if ( !locked )
{
highlighted = highlight;
if ( highlight )
{
areaMesh.material = Teleport.instance.areaHighlightedMaterial;
}
else
{
areaMesh.material = Teleport.instance.areaVisibleMaterial;
}
}
}
//-------------------------------------------------
public override void SetAlpha( float tintAlpha, float alphaPercent )
{
Color tintedColor = GetTintColor();
tintedColor.a *= alphaPercent;
areaMesh.material.SetColor( tintColorId, tintedColor );
}
//-------------------------------------------------
public override void UpdateVisuals()
{
if ( locked )
{
areaMesh.material = Teleport.instance.areaLockedMaterial;
}
else
{
areaMesh.material = Teleport.instance.areaVisibleMaterial;
}
}
//-------------------------------------------------
public void UpdateVisualsInEditor()
{
areaMesh = GetComponent<MeshRenderer>();
if ( locked )
{
areaMesh.sharedMaterial = Teleport.instance.areaLockedMaterial;
}
else
{
areaMesh.sharedMaterial = Teleport.instance.areaVisibleMaterial;
}
}
//-------------------------------------------------
private bool CalculateBounds()
{
MeshFilter meshFilter = GetComponent<MeshFilter>();
if ( meshFilter == null )
{
return false;
}
Mesh mesh = meshFilter.sharedMesh;
if ( mesh == null )
{
return false;
}
meshBounds = mesh.bounds;
return true;
}
//-------------------------------------------------
private Color GetTintColor()
{
if ( locked )
{
return lockedTintColor;
}
else
{
if ( highlighted )
{
return highlightedTintColor;
}
else
{
return visibleTintColor;
}
}
}
}
#if UNITY_EDITOR
//-------------------------------------------------------------------------
[CustomEditor( typeof( TeleportArea ) )]
public class TeleportAreaEditor : Editor
{
//-------------------------------------------------
void OnEnable()
{
if ( Selection.activeTransform != null )
{
TeleportArea teleportArea = Selection.activeTransform.GetComponent<TeleportArea>();
if ( teleportArea != null )
{
teleportArea.UpdateVisualsInEditor();
}
}
}
//-------------------------------------------------
public override void OnInspectorGUI()
{
DrawDefaultInspector();
if ( Selection.activeTransform != null )
{
TeleportArea teleportArea = Selection.activeTransform.GetComponent<TeleportArea>();
if ( GUI.changed && teleportArea != null )
{
teleportArea.UpdateVisualsInEditor();
}
}
}
}
#endif
}