// --------------------------------------------------------------------------------------------------------------------
//
// Copyright (c) VRMADA, All rights reserved.
//
// --------------------------------------------------------------------------------------------------------------------
using System;
using UltimateXR.Haptics;
using UltimateXR.UI.UnityInputModule.Controls;
using UnityEngine;
namespace UltimateXR.UI
{
///
/// Defines sound and haptic feedback for pressing events. Each , for instance, has a
/// for each of its click/down/up events.
///
[Serializable]
public class UxrControlFeedback
{
#region Inspector Properties/Serialized Fields
[SerializeField] private UxrHapticClip _hapticClip = new UxrHapticClip();
[SerializeField] private AudioClip _audioClip;
[SerializeField] [Range(0, 1)] private float _audioVolume = 1.0f;
[SerializeField] private bool _useAudio3D = true;
#endregion
#region Public Types & Data
///
/// Gets or sets the haptic clip.
///
public UxrHapticClip HapticClip
{
get => _hapticClip;
set => _hapticClip = value;
}
///
/// Gets or sets the audio clip.
///
public AudioClip AudioClip
{
get => _audioClip;
set => _audioClip = value;
}
///
/// Gets or sets the audio volume.
///
public float AudioVolume
{
get => _audioVolume;
set => _audioVolume = value;
}
///
/// Gets or sets whether to use 3D audio.
///
public bool UseAudio3D
{
get => _useAudio3D;
set => _useAudio3D = value;
}
#endregion
#region Constructors & Finalizer
///
/// Default constructor.
///
public UxrControlFeedback()
{
}
///
/// Constructor allowing to define the haptic clip.
///
/// Haptic clip to play on the event
public UxrControlFeedback(UxrHapticClip hapticClip)
{
HapticClip = hapticClip;
}
#endregion
#region Public Types & Data
///
/// Subtle click
///
public static UxrControlFeedback FeedbackDown = new UxrControlFeedback(new UxrHapticClip(null, UxrHapticClipType.Click, UxrHapticMode.Mix, 1.0f, 0.2f));
///
/// No feedback
///
public static UxrControlFeedback FeedbackUp = new UxrControlFeedback(new UxrHapticClip());
///
/// Regular click
///
public static UxrControlFeedback FeedbackClick = new UxrControlFeedback(new UxrHapticClip(null, UxrHapticClipType.Click, UxrHapticMode.Mix, 1.0f, 0.6f));
#endregion
}
}