- LocalizationManager: 新增翻译表(SetFormatted/SetDuration/LocalizeOperateMsg) - LoginPanel: InputField placeholder本地化、字体颜色保持 - HistoryPanel: 用时数据本地化、placeholder本地化 - RecordDetailPanel: 操作详情消息本地化(LanguageChanged重建) - AppraiseWindowBase: 评价等级本地化、操作消息重建 - EditorAppraiser: 所有评估消息改用InjectOperateMsgLocalized - StudentOperateRecorder: 新增InjectOperateMsgLocalized方法 - LocalizationLanguageTestBar: 单例模式、ScreenSpaceOverlay筛选 - 字体切换时保留颜色和verticalOverflow
87 lines
2.6 KiB
Plaintext
87 lines
2.6 KiB
Plaintext
#if VRTK_DEFINE_SDK_DAYDREAM
|
|
namespace VRTK
|
|
{
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// DaydreamReach component uses touchpad to extend controller position out in front of user
|
|
/// along the current controller orientation plane
|
|
/// </summary>
|
|
public class DaydreamReach : MonoBehaviour
|
|
{
|
|
[Tooltip("Controller to track, defaults to ./Controller but probably want a Pointer Joint like GvrControllerPointer/Laser")]
|
|
public Transform controller;
|
|
[Tooltip("Maximum reach distance from controller origin.")]
|
|
public float reachDistance = 0.5f;
|
|
|
|
private Vector3 positionOrigin;
|
|
|
|
protected virtual void Start()
|
|
{
|
|
if (controller == null)
|
|
{
|
|
controller = transform.FindChild("Controller");
|
|
}
|
|
positionOrigin = transform.position;
|
|
}
|
|
|
|
protected virtual void Update()
|
|
{
|
|
if (!GvrController.IsTouching)
|
|
{
|
|
// snap back to origin
|
|
transform.position = positionOrigin;
|
|
}
|
|
else
|
|
{
|
|
transform.position = ReachForwardByDistance();
|
|
}
|
|
}
|
|
|
|
private Vector3 ReachForwardByDistance()
|
|
{
|
|
Vector3 pos = positionOrigin;
|
|
Vector3 offset = Vector3.zero;
|
|
Vector2 touch = GetTouch(5);
|
|
|
|
offset.z = touch.y * reachDistance;
|
|
offset = controller.transform.rotation * offset;
|
|
pos += offset;
|
|
return pos;
|
|
}
|
|
|
|
/// <summary>
|
|
/// GetTouch gets touch position adjusted coordinates. Abs(x) and abs(y) always 0 to 1
|
|
/// </summary>
|
|
/// <param name="origin">like a numeric keypad, 1= lower left, 2=lower-center, 5=center etc</param>
|
|
/// <returns>A Vector2 of the touch position.</returns>
|
|
private Vector2 GetTouch(int origin = 5)
|
|
{
|
|
if (!GvrController.IsTouching)
|
|
{
|
|
return Vector2.zero;
|
|
}
|
|
|
|
Vector2 touch = GvrController.TouchPos;
|
|
// raw: 0,0 is top left, x is left-right, y is front-back
|
|
// invert y axis
|
|
touch.y = 1.0f - touch.y;
|
|
|
|
switch (origin)
|
|
{
|
|
case 1:
|
|
break;
|
|
case 2:
|
|
touch.x = touch.x * 2f - 1f;
|
|
break;
|
|
case 5:
|
|
touch.y = touch.y * 2f - 1f;
|
|
touch.x = touch.x * 2f - 1f;
|
|
break;
|
|
}
|
|
|
|
return touch;
|
|
}
|
|
}
|
|
}
|
|
#endif |