fix: stabilize VR UI and song playback
This commit is contained in:
@@ -4551,9 +4551,11 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 2094521061}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 3f8ab482667b2f44691ffe7131ffbdb7, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 504eaffe3c185bf469313a589c4026d0, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
button: {fileID: 2094521063}
|
||||
sceneName: Menu
|
||||
--- !u!1 &2138780048
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -4893,12 +4895,12 @@ PrefabInstance:
|
||||
- target: {fileID: 3968956848465607219, guid: f555cbb0b089fb64ca7c7a5b07f11520,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
value: 0.9238795
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3968956848465607219, guid: f555cbb0b089fb64ca7c7a5b07f11520,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: -0
|
||||
value: 0.38268343
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3968956848465607219, guid: f555cbb0b089fb64ca7c7a5b07f11520,
|
||||
type: 3}
|
||||
@@ -4913,7 +4915,7 @@ PrefabInstance:
|
||||
- target: {fileID: 3968956848465607219, guid: f555cbb0b089fb64ca7c7a5b07f11520,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
value: 45
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3968956848465607219, guid: f555cbb0b089fb64ca7c7a5b07f11520,
|
||||
type: 3}
|
||||
@@ -5103,12 +5105,12 @@ PrefabInstance:
|
||||
- target: {fileID: 1002067974212273307, guid: e7173b1ee3369204eb181b376ede2a3e,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 1
|
||||
value: 0.9238795
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1002067974212273307, guid: e7173b1ee3369204eb181b376ede2a3e,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: -0
|
||||
value: 0.38268343
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1002067974212273307, guid: e7173b1ee3369204eb181b376ede2a3e,
|
||||
type: 3}
|
||||
@@ -5123,7 +5125,7 @@ PrefabInstance:
|
||||
- target: {fileID: 1002067974212273307, guid: e7173b1ee3369204eb181b376ede2a3e,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.x
|
||||
value: 0
|
||||
value: 45
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1002067974212273307, guid: e7173b1ee3369204eb181b376ede2a3e,
|
||||
type: 3}
|
||||
|
||||
@@ -8,16 +8,64 @@ namespace VRBeats
|
||||
// 나머지 씬: 바로 활성 상태로 추가.
|
||||
public class VRPointerSetup : MonoBehaviour
|
||||
{
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterSceneLoad)]
|
||||
private static VRPointerSetup instance;
|
||||
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
|
||||
private static void ResetStatics()
|
||||
{
|
||||
instance = null;
|
||||
}
|
||||
|
||||
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
|
||||
private static void AutoInject()
|
||||
{
|
||||
if (instance != null)
|
||||
return;
|
||||
|
||||
var go = new GameObject("[VRPointerSetup]");
|
||||
go.AddComponent<VRPointerSetup>();
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (instance != null && instance != this)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
|
||||
instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
SceneManager.sceneLoaded += OnSceneLoaded;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
SceneManager.sceneLoaded -= OnSceneLoaded;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
bool isGameScene = SceneManager.GetActiveScene().name == "Game";
|
||||
SetupActiveScene();
|
||||
}
|
||||
|
||||
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
||||
{
|
||||
SetupScene(scene);
|
||||
}
|
||||
|
||||
private static void SetupActiveScene()
|
||||
{
|
||||
SetupScene(SceneManager.GetActiveScene());
|
||||
}
|
||||
|
||||
private static void SetupScene(Scene scene)
|
||||
{
|
||||
bool isGameScene = scene.name == "Game";
|
||||
SetupControllers(disabledByDefault: isGameScene);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ namespace VRBeats
|
||||
[SerializeField] private float fadeOutTime = 4.0f;
|
||||
|
||||
private AudioSource audioSource = null;
|
||||
private double scheduledDspStartTime = -1.0;
|
||||
private bool hasScheduledClip = false;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
@@ -43,13 +45,37 @@ namespace VRBeats
|
||||
|
||||
public void PlayClip(AudioClip clip)
|
||||
{
|
||||
audioSource.clip = clip;
|
||||
audioSource.Play();
|
||||
PlayClipScheduled(clip);
|
||||
}
|
||||
|
||||
public float CurrentTime => audioSource != null ? audioSource.time : 0f;
|
||||
public double PlayClipScheduled(AudioClip clip, double delaySeconds = 0.1)
|
||||
{
|
||||
ResetThisComponent();
|
||||
audioSource.Stop();
|
||||
audioSource.clip = clip;
|
||||
audioSource.time = 0.0f;
|
||||
|
||||
scheduledDspStartTime = AudioSettings.dspTime + delaySeconds;
|
||||
hasScheduledClip = true;
|
||||
audioSource.PlayScheduled(scheduledDspStartTime);
|
||||
|
||||
return scheduledDspStartTime;
|
||||
}
|
||||
|
||||
public float CurrentTime
|
||||
{
|
||||
get
|
||||
{
|
||||
if (audioSource == null)
|
||||
return 0.0f;
|
||||
|
||||
if (hasScheduledClip)
|
||||
return (float)(AudioSettings.dspTime - scheduledDspStartTime);
|
||||
|
||||
return audioSource.time;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -23,23 +23,48 @@ namespace VRBeats
|
||||
|
||||
public void DisableXRRayInteractorComponents()
|
||||
{
|
||||
rayInteractor.enabled = false;
|
||||
interactorLineVisual.enabled = false;
|
||||
lineRender.enabled = false;
|
||||
if (rayInteractor != null)
|
||||
rayInteractor.enabled = false;
|
||||
if (interactorLineVisual != null)
|
||||
interactorLineVisual.enabled = false;
|
||||
if (lineRender != null)
|
||||
lineRender.enabled = false;
|
||||
|
||||
// VRPointerController는 부모("LeftHand/RightHand Controller")에 추가되므로 InParent로 탐색
|
||||
var pointer = GetComponentInParent<VRPointerController>();
|
||||
if (pointer != null) pointer.enabled = false;
|
||||
// VRPointerController 위치가 컨트롤러/레이 구조에 따라 달라질 수 있어서 계층 전체에서 찾는다.
|
||||
var pointer = FindPointerController();
|
||||
if (pointer != null)
|
||||
pointer.enabled = false;
|
||||
}
|
||||
|
||||
public void EnableXRRayInteractorComponents()
|
||||
{
|
||||
rayInteractor.enabled = true;
|
||||
interactorLineVisual.enabled = true;
|
||||
lineRender.enabled = true;
|
||||
if (rayInteractor != null)
|
||||
rayInteractor.enabled = true;
|
||||
if (interactorLineVisual != null)
|
||||
interactorLineVisual.enabled = true;
|
||||
if (lineRender != null)
|
||||
lineRender.enabled = true;
|
||||
|
||||
var pointer = GetComponentInParent<VRPointerController>();
|
||||
if (pointer != null) pointer.enabled = true;
|
||||
var pointer = FindPointerController();
|
||||
if (pointer != null)
|
||||
pointer.enabled = true;
|
||||
}
|
||||
|
||||
private VRPointerController FindPointerController()
|
||||
{
|
||||
var pointer = GetComponent<VRPointerController>();
|
||||
if (pointer != null)
|
||||
return pointer;
|
||||
|
||||
pointer = GetComponentInParent<VRPointerController>();
|
||||
if (pointer != null)
|
||||
return pointer;
|
||||
|
||||
pointer = GetComponentInChildren<VRPointerController>(true);
|
||||
if (pointer != null)
|
||||
return pointer;
|
||||
|
||||
return transform.root.GetComponentInChildren<VRPointerController>(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user