/// ---------------------------------------------
/// Ultimate Character Controller
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.UltimateCharacterController.Input
{
using UnityEngine;
using Opsive.UltimateCharacterController.Input.VirtualControls;
///
/// Uses virtual buttons to detect input related actions.
///
public class VirtualInput : InputBase
{
private VirtualControlsManager m_VirtualControlsManager;
///
/// Associates the VirtualControlsManager with the VirtualInput object.
///
/// The VirtualControlsManager to associate with the VirtualInput object.
public void RegisterVirtualControlsManager(VirtualControlsManager virtualControlsManager)
{
m_VirtualControlsManager = virtualControlsManager;
}
///
/// Removes the VirtualControlsManager association.
///
public void UnregisterVirtualControlsManager()
{
m_VirtualControlsManager = null;
}
///
/// Returns the axis of the specified button.
///
/// The name of the axis.
/// The axis value.
public override float GetAxis(string name)
{
if (m_VirtualControlsManager == null) {
return 0;
}
return m_VirtualControlsManager.GetAxis(name);
}
///
/// Returns the raw axis of the specified button.
///
/// The name of the axis.
/// The raw axis value.
public override float GetAxisRaw(string axisName)
{
if (m_VirtualControlsManager == null) {
return 0;
}
return m_VirtualControlsManager.GetAxis(axisName);
}
///
/// Returns if the button is true with the specified ButtonAction.
///
/// The name of the button.
/// The type of action to check.
/// The status of the action.
public override bool GetButton(string name, ButtonAction action)
{
if (m_VirtualControlsManager == null) {
return false;
}
return m_VirtualControlsManager.GetButton(name, action);
}
}
}