unityzgy/.svn/pristine/3f/3ff354c2a0aba27204f7611fafa2da7b9ba600f9.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

67 lines
2.7 KiB
Plaintext

// Custom Joint Grab Attach|GrabAttachMechanics|50060
namespace VRTK.GrabAttachMechanics
{
using UnityEngine;
/// <summary>
/// The Custom Joint Grab Attach script allows a custom joint to be provided for the grab attach mechanic.
/// </summary>
/// <remarks>
/// The custom joint is placed on the interactable object and at runtime the joint is copied into a `JointHolder` game object that becomes a child of the interactable object.
///
/// The custom joint is then copied from this `JointHolder` to the interactable object when a grab happens and is removed when a grab ends.
/// </remarks>
/// <example>
/// `VRTK/Examples/021_Controller_GrabbingObjectsWithJoints` demonstrates this grab attach mechanic on the Lamp object in the scene.
/// </example>
[AddComponentMenu("VRTK/Scripts/Interactions/Grab Attach Mechanics/VRTK_CustomJointGrabAttach")]
public class VRTK_CustomJointGrabAttach : VRTK_BaseJointGrabAttach
{
[Tooltip("The joint to use for the grab attach joint.")]
public Joint customJoint;
protected GameObject jointHolder;
protected override void Initialise()
{
base.Initialise();
CopyCustomJoint();
}
protected override void CreateJoint(GameObject obj)
{
if (!jointHolder)
{
VRTK_Logger.Error(VRTK_Logger.GetCommonMessage(VRTK_Logger.CommonMessageKeys.REQUIRED_COMPONENT_MISSING_NOT_INJECTED, "VRTK_CustomJointGrabAttach", "Joint", "customJoint", "the same"));
return;
}
var storedJoint = jointHolder.GetComponent<Joint>();
var storeName = gameObject.name;
VRTK_SharedMethods.CloneComponent(storedJoint, obj, true);
gameObject.name = storeName;
givenJoint = obj.GetComponent(storedJoint.GetType()) as Joint;
base.CreateJoint(obj);
}
protected override void DestroyJoint(bool withDestroyImmediate, bool applyGrabbingObjectVelocity)
{
base.DestroyJoint(true, true);
}
protected virtual void CopyCustomJoint()
{
if (customJoint)
{
jointHolder = new GameObject();
jointHolder.transform.SetParent(transform);
jointHolder.AddComponent<Rigidbody>().isKinematic = true;
VRTK_SharedMethods.CloneComponent(customJoint, jointHolder, true);
jointHolder.name = VRTK_SharedMethods.GenerateVRTKObjectName(true, "JointHolder");
jointHolder.SetActive(false);
Destroy(customJoint);
customJoint = jointHolder.GetComponent<Joint>();
}
}
}
}