unityzgy/.svn/pristine/22/22182abae75d1105f484f54bf0bc1828ef274036.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

58 lines
2.5 KiB
Plaintext

// Content Handler|Controls3D|100100
namespace VRTK
{
using UnityEngine;
/// <summary>
/// Manages objects defined as content. When taking out an object from a drawer and closing the drawer this object would otherwise disappear even if outside the drawer.
/// </summary>
/// <remarks>
/// The script will use the boundaries of the control to determine if it is in or out and re-parent the object as necessary. It can be put onto individual objects or the parent of multiple objects. Using the latter way all interactable objects under that parent will become managed by the script.
/// </remarks>
/// <example>
/// `VRTK/Examples/025_Controls_Overview` has a drawer with a collection of items that adhere to this concept.
/// </example>
public class VRTK_ContentHandler : MonoBehaviour
{
[Tooltip("The 3D control responsible for the content.")]
public VRTK_Control control;
[Tooltip("The transform containing the meshes or colliders that define the inside of the control.")]
public Transform inside;
[Tooltip("Any transform that will act as the parent while the object is not inside the control.")]
public Transform outside;
protected virtual void Start()
{
VRTK_InteractableObject contentInteractableObject = GetComponent<VRTK_InteractableObject>();
if (contentInteractableObject == null)
{
// treat as parent and assign to all children
foreach (var childIo in GetComponentsInChildren<VRTK_InteractableObject>())
{
if (childIo.GetComponent<VRTK_ContentHandler>() == null)
{
VRTK_ContentHandler childContentHandler = childIo.gameObject.AddComponent<VRTK_ContentHandler>();
childContentHandler.control = control;
childContentHandler.inside = inside;
childContentHandler.outside = outside;
}
}
}
}
protected virtual void OnCollisionEnter(Collision collision)
{
Bounds insideBounds = VRTK_SharedMethods.GetBounds(inside, null, control.GetContent().transform);
Bounds objBounds = VRTK_SharedMethods.GetBounds(transform);
if (objBounds.Intersects(insideBounds))
{
transform.SetParent(control.GetContent().transform);
}
else
{
transform.SetParent(outside);
}
}
}
}