Some fixes made, object picking logic added
This commit is contained in:
@@ -32,7 +32,7 @@ public class FloorButtonVisualizer : MonoBehaviour
|
||||
{
|
||||
buttonImage.sprite = ActiveSprite;
|
||||
// Play FMOD sound here
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Hover, gameObject);
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Hover, buttonImage.gameObject);
|
||||
}
|
||||
|
||||
public void OnDeselect(BaseEventData eventData) // joystick moves away
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
using UnityEngine;
|
||||
using static FMODEvents;
|
||||
|
||||
public class GrabAudioProfile : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GrabSoundType grabSoundType = GrabSoundType.Default;
|
||||
|
||||
public GrabSoundType GrabSoundType => grabSoundType;
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7405dee79e06eca4795d2d3f39801f47
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -23,7 +23,7 @@ public class HoverSlideButton : MonoBehaviour, IPointerEnterHandler, IPointerExi
|
||||
public void OnPointerEnter(PointerEventData eventData)
|
||||
{
|
||||
SlideToPosition(onPosition);
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Hover, gameObject); //3d oneshot sound
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Hover, buttonTransform.gameObject); //3d oneshot sound
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData)
|
||||
|
||||
@@ -91,7 +91,7 @@ public class MenuTeleportButton : MonoBehaviour
|
||||
button.targetGraphic.GetComponent<Image>().sprite = HoverSprite;
|
||||
}
|
||||
// Play FMOD hover sound
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Hover, gameObject);
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Hover, button.gameObject);
|
||||
}
|
||||
|
||||
public void OnDeselect(BaseEventData eventData)
|
||||
|
||||
@@ -2,6 +2,8 @@ using _PROJECT.NewHandPresence;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.XR.Interaction.Toolkit;
|
||||
using static FMODEvents;
|
||||
using FMODUnity;
|
||||
|
||||
public class TutorialAudioListener : MonoBehaviour
|
||||
{
|
||||
@@ -61,6 +63,9 @@ public class TutorialAudioListener : MonoBehaviour
|
||||
locomotionConfigurator.OnLocomotionToggled += HandleLocomotionToggled;
|
||||
locomotionConfigurator.OnSpeedChanged += HandleSpeedChanged;
|
||||
}
|
||||
|
||||
if (tutorialController != null)
|
||||
tutorialController.OnGrab += HandleGrab;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
@@ -82,6 +87,8 @@ public class TutorialAudioListener : MonoBehaviour
|
||||
locomotionConfigurator.OnLocomotionToggled -= HandleLocomotionToggled;
|
||||
locomotionConfigurator.OnSpeedChanged -= HandleSpeedChanged;
|
||||
}
|
||||
if (tutorialController != null)
|
||||
tutorialController.OnGrab -= HandleGrab;
|
||||
}
|
||||
|
||||
private void HandleLocomotionToggled(bool enabled)
|
||||
@@ -158,4 +165,42 @@ public class TutorialAudioListener : MonoBehaviour
|
||||
AudioManager.Instance.PlayAttachedInstance(FMODEvents.Instance.Steps, gameObject);
|
||||
Debug.Log("[TeleportationListen] Teleport sound played.");
|
||||
}
|
||||
|
||||
private EventReference GetGrabEvent(GrabSoundType type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case GrabSoundType.Bow:
|
||||
return FMODEvents.Instance.BowGrab;
|
||||
|
||||
case GrabSoundType.Sprayer:
|
||||
return FMODEvents.Instance.SprayerGrab;
|
||||
|
||||
//Add more objects for grabbing here and do not forget to define them in FMODEvents.cs
|
||||
//Add the GrabAudioProfile.cs component to an object instance
|
||||
|
||||
default:
|
||||
return FMODEvents.Instance.DefaultGrab;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void HandleGrab(XRGrabInteractable grab)
|
||||
{
|
||||
if (grab == null)
|
||||
return;
|
||||
|
||||
var profile = grab.GetComponent<GrabAudioProfile>();
|
||||
GrabSoundType type = profile != null
|
||||
? profile.GrabSoundType
|
||||
: GrabSoundType.Default;
|
||||
|
||||
EventReference grabEvent = GetGrabEvent(type);
|
||||
Debug.Log(grabEvent);
|
||||
AudioManager.Instance.PlayAttachedInstance(grabEvent, grab.gameObject);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace _PROJECT.NewHandPresence
|
||||
|
||||
private List<XRGrabInteractable> _grabInteractables = new List<XRGrabInteractable>();
|
||||
private XRGrabInteractable _grabInteractable;
|
||||
public event Action<XRGrabInteractable> OnGrab;
|
||||
|
||||
private GameObject _billboard;
|
||||
|
||||
@@ -219,6 +220,11 @@ namespace _PROJECT.NewHandPresence
|
||||
|
||||
private void OnGripPerformed(SelectEnterEventArgs arg0)
|
||||
{
|
||||
var grab = arg0.interactableObject as XRGrabInteractable;
|
||||
|
||||
// Notify any listeners
|
||||
OnGrab?.Invoke(grab);
|
||||
|
||||
if (_state != TutorialState.Grip) return;
|
||||
Debug.Log("Grip performed");
|
||||
UpdateState(_state.Next());
|
||||
|
||||
Reference in New Issue
Block a user