- LocalizationManager: 新增翻译表(SetFormatted/SetDuration/LocalizeOperateMsg) - LoginPanel: InputField placeholder本地化、字体颜色保持 - HistoryPanel: 用时数据本地化、placeholder本地化 - RecordDetailPanel: 操作详情消息本地化(LanguageChanged重建) - AppraiseWindowBase: 评价等级本地化、操作消息重建 - EditorAppraiser: 所有评估消息改用InjectOperateMsgLocalized - StudentOperateRecorder: 新增InjectOperateMsgLocalized方法 - LocalizationLanguageTestBar: 单例模式、ScreenSpaceOverlay筛选 - 字体切换时保留颜色和verticalOverflow
60 lines
2.3 KiB
C#
60 lines
2.3 KiB
C#
namespace VRTK.Examples.Archery
|
|
{
|
|
using UnityEngine;
|
|
|
|
public class ArrowSpawner : MonoBehaviour
|
|
{
|
|
public GameObject arrowPrefab;
|
|
public float spawnDelay = 1f;
|
|
|
|
private float spawnDelayTimer = 0f;
|
|
private BowAim bow;
|
|
|
|
private void Start()
|
|
{
|
|
spawnDelayTimer = 0f;
|
|
}
|
|
|
|
private void OnTriggerStay(Collider collider)
|
|
{
|
|
VRTK_InteractGrab grabbingController = (collider.gameObject.GetComponent<VRTK_InteractGrab>() ? collider.gameObject.GetComponent<VRTK_InteractGrab>() : collider.gameObject.GetComponentInParent<VRTK_InteractGrab>());
|
|
if (CanGrab(grabbingController) && NoArrowNotched(grabbingController.gameObject) && Time.time >= spawnDelayTimer)
|
|
{
|
|
GameObject newArrow = Instantiate(arrowPrefab);
|
|
newArrow.name = "ArrowClone";
|
|
grabbingController.GetComponent<VRTK_InteractTouch>().ForceTouch(newArrow);
|
|
grabbingController.AttemptGrab();
|
|
spawnDelayTimer = Time.time + spawnDelay;
|
|
}
|
|
}
|
|
|
|
private bool CanGrab(VRTK_InteractGrab grabbingController)
|
|
{
|
|
return (grabbingController && grabbingController.GetGrabbedObject() == null && grabbingController.IsGrabButtonPressed());
|
|
}
|
|
|
|
private bool NoArrowNotched(GameObject controller)
|
|
{
|
|
if (VRTK_DeviceFinder.IsControllerLeftHand(controller))
|
|
{
|
|
GameObject controllerRightHand = VRTK_DeviceFinder.GetControllerRightHand(true);
|
|
bow = controllerRightHand.GetComponentInChildren<BowAim>();
|
|
if (bow == null)
|
|
{
|
|
bow = VRTK_DeviceFinder.GetModelAliasController(controllerRightHand).GetComponentInChildren<BowAim>();
|
|
}
|
|
}
|
|
else if (VRTK_DeviceFinder.IsControllerRightHand(controller))
|
|
{
|
|
GameObject controllerLeftHand = VRTK_DeviceFinder.GetControllerLeftHand(true);
|
|
bow = controllerLeftHand.GetComponentInChildren<BowAim>();
|
|
if (bow == null)
|
|
{
|
|
bow = VRTK_DeviceFinder.GetModelAliasController(controllerLeftHand).GetComponentInChildren<BowAim>();
|
|
}
|
|
}
|
|
|
|
return (bow == null || !bow.HasArrow());
|
|
}
|
|
}
|
|
} |