forked from cgvr/DeltaVR
radio button is disabled before radio is grabbed
This commit is contained in:
Binary file not shown.
@@ -12,6 +12,7 @@ public class ReleasableButton : MonoBehaviour
|
|||||||
public float moveDuration = 0.25f;
|
public float moveDuration = 0.25f;
|
||||||
public float moveAmount = 0.05f;
|
public float moveAmount = 0.05f;
|
||||||
|
|
||||||
|
private bool isLocked;
|
||||||
private float upPositionY;
|
private float upPositionY;
|
||||||
private float downPositionY;
|
private float downPositionY;
|
||||||
|
|
||||||
@@ -43,7 +44,7 @@ public class ReleasableButton : MonoBehaviour
|
|||||||
private void OnTriggerEnter(Collider collider)
|
private void OnTriggerEnter(Collider collider)
|
||||||
{
|
{
|
||||||
// if button is up, start moving down
|
// if button is up, start moving down
|
||||||
if (buttonState == 0 && collider.gameObject.tag.EndsWith("Hand"))
|
if (buttonState == 0 &&!isLocked && collider.gameObject.tag.EndsWith("Hand"))
|
||||||
{
|
{
|
||||||
Activate();
|
Activate();
|
||||||
OnButtonPressed?.Invoke();
|
OnButtonPressed?.Invoke();
|
||||||
@@ -53,7 +54,7 @@ public class ReleasableButton : MonoBehaviour
|
|||||||
private void OnTriggerExit(Collider collider)
|
private void OnTriggerExit(Collider collider)
|
||||||
{
|
{
|
||||||
// if button is down, start moving up
|
// if button is down, start moving up
|
||||||
if (buttonState == 1 && collider.gameObject.tag.EndsWith("Hand"))
|
if (buttonState == 1 && !isLocked && collider.gameObject.tag.EndsWith("Hand"))
|
||||||
{
|
{
|
||||||
Deactivate();
|
Deactivate();
|
||||||
OnButtonReleased?.Invoke();
|
OnButtonReleased?.Invoke();
|
||||||
@@ -81,4 +82,14 @@ public class ReleasableButton : MonoBehaviour
|
|||||||
|
|
||||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Click, gameObject);
|
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Click, gameObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Lock()
|
||||||
|
{
|
||||||
|
isLocked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Unlock()
|
||||||
|
{
|
||||||
|
isLocked = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System.Threading.Tasks;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.XR.Interaction.Toolkit;
|
using UnityEngine.XR.Interaction.Toolkit;
|
||||||
@@ -22,6 +23,7 @@ public class RadioTransmitter : XRGrabInteractable
|
|||||||
{
|
{
|
||||||
radioButton.OnButtonPressed += OnRadioButtonPressed;
|
radioButton.OnButtonPressed += OnRadioButtonPressed;
|
||||||
radioButton.OnButtonReleased += OnRadioButtonReleased;
|
radioButton.OnButtonReleased += OnRadioButtonReleased;
|
||||||
|
radioButton.Lock();
|
||||||
isProcessing = false;
|
isProcessing = false;
|
||||||
|
|
||||||
var emission = particles.emission;
|
var emission = particles.emission;
|
||||||
@@ -34,10 +36,13 @@ public class RadioTransmitter : XRGrabInteractable
|
|||||||
particles.transform.LookAt(computerScreen.transform.position);
|
particles.transform.LookAt(computerScreen.transform.position);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnSelectEntered(SelectEnterEventArgs args)
|
protected async override void OnSelectEntered(SelectEnterEventArgs args)
|
||||||
{
|
{
|
||||||
base.OnSelectEntered(args);
|
base.OnSelectEntered(args);
|
||||||
OnPlayerPickUp?.Invoke();
|
OnPlayerPickUp?.Invoke();
|
||||||
|
|
||||||
|
await Task.Delay(100);
|
||||||
|
radioButton.Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnRadioButtonPressed()
|
private void OnRadioButtonPressed()
|
||||||
|
|||||||
Reference in New Issue
Block a user