unityzgy/.svn/pristine/16/16945d390fecf336ed69bff341488f395c0d02ba.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

76 lines
1.7 KiB
Plaintext

//======= Copyright (c) Valve Corporation, All rights reserved. ===============
//
// Purpose: Play one-shot sounds as opposed to continuos/looping ones
//
//=============================================================================
using UnityEngine;
using System.Collections;
namespace Valve.VR.InteractionSystem
{
//-------------------------------------------------------------------------
public class SoundPlayOneshot : MonoBehaviour
{
public AudioClip[] waveFiles;
private AudioSource thisAudioSource;
public float volMin;
public float volMax;
public float pitchMin;
public float pitchMax;
public bool playOnAwake;
//-------------------------------------------------
void Awake()
{
thisAudioSource = GetComponent<AudioSource>();
if ( playOnAwake )
{
Play();
}
}
//-------------------------------------------------
public void Play()
{
if ( thisAudioSource != null && thisAudioSource.isActiveAndEnabled && !Util.IsNullOrEmpty( waveFiles ) )
{
//randomly apply a volume between the volume min max
thisAudioSource.volume = Random.Range( volMin, volMax );
//randomly apply a pitch between the pitch min max
thisAudioSource.pitch = Random.Range( pitchMin, pitchMax );
// play the sound
thisAudioSource.PlayOneShot( waveFiles[Random.Range( 0, waveFiles.Length )] );
}
}
//-------------------------------------------------
public void Pause()
{
if ( thisAudioSource != null )
{
thisAudioSource.Pause();
}
}
//-------------------------------------------------
public void UnPause()
{
if ( thisAudioSource != null )
{
thisAudioSource.UnPause();
}
}
}
}