- LocalizationManager: 新增翻译表(SetFormatted/SetDuration/LocalizeOperateMsg) - LoginPanel: InputField placeholder本地化、字体颜色保持 - HistoryPanel: 用时数据本地化、placeholder本地化 - RecordDetailPanel: 操作详情消息本地化(LanguageChanged重建) - AppraiseWindowBase: 评价等级本地化、操作消息重建 - EditorAppraiser: 所有评估消息改用InjectOperateMsgLocalized - StudentOperateRecorder: 新增InjectOperateMsgLocalized方法 - LocalizationLanguageTestBar: 单例模式、ScreenSpaceOverlay筛选 - 字体切换时保留颜色和verticalOverflow
69 lines
2.1 KiB
C#
69 lines
2.1 KiB
C#
namespace VRTK.Examples
|
|
{
|
|
using UnityEngine;
|
|
|
|
public class LightSaber : VRTK_InteractableObject
|
|
{
|
|
private bool beamActive = false;
|
|
private Vector2 beamLimits = new Vector2(0f, 1.2f);
|
|
private float currentBeamSize;
|
|
private float beamExtendSpeed = 0;
|
|
|
|
private GameObject blade;
|
|
private Color activeColor;
|
|
private Color targetColor;
|
|
private Color[] bladePhaseColors;
|
|
|
|
public override void StartUsing(VRTK_InteractUse usingObject)
|
|
{
|
|
base.StartUsing(usingObject);
|
|
beamExtendSpeed = 5f;
|
|
bladePhaseColors = new Color[2] { Color.blue, Color.cyan };
|
|
activeColor = bladePhaseColors[0];
|
|
targetColor = bladePhaseColors[1];
|
|
}
|
|
|
|
public override void StopUsing(VRTK_InteractUse usingObject)
|
|
{
|
|
base.StopUsing(usingObject);
|
|
beamExtendSpeed = -5f;
|
|
}
|
|
|
|
protected void Start()
|
|
{
|
|
blade = transform.Find("Blade").gameObject;
|
|
currentBeamSize = beamLimits.x;
|
|
SetBeamSize();
|
|
}
|
|
|
|
protected override void Update()
|
|
{
|
|
base.Update();
|
|
currentBeamSize = Mathf.Clamp(blade.transform.localScale.y + (beamExtendSpeed * Time.deltaTime), beamLimits.x, beamLimits.y);
|
|
SetBeamSize();
|
|
PulseBeam();
|
|
}
|
|
|
|
private void SetBeamSize()
|
|
{
|
|
blade.transform.localScale = new Vector3(1f, currentBeamSize, 1f);
|
|
beamActive = (currentBeamSize >= beamLimits.y ? true : false);
|
|
}
|
|
|
|
private void PulseBeam()
|
|
{
|
|
if (beamActive)
|
|
{
|
|
Color bladeColor = Color.Lerp(activeColor, targetColor, Mathf.PingPong(Time.time, 1));
|
|
blade.transform.Find("Beam").GetComponent<MeshRenderer>().material.color = bladeColor;
|
|
|
|
if (bladeColor == targetColor)
|
|
{
|
|
var previouslyActiveColor = activeColor;
|
|
activeColor = targetColor;
|
|
targetColor = previouslyActiveColor;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |