131 lines
3.0 KiB
C#
131 lines
3.0 KiB
C#
using Invector.vCharacterController;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using System.Collections;
|
|
using UnityEngine.UI;
|
|
using UnityStandardAssets.CrossPlatformInput;
|
|
|
|
namespace Beyond
|
|
{
|
|
public class ButtonHandler : MonoBehaviour
|
|
{
|
|
public string Name;
|
|
|
|
public void SetDownState()
|
|
{
|
|
CrossPlatformInputManager.SetButtonDown(Name);
|
|
}
|
|
|
|
public void Click()
|
|
{
|
|
StartCoroutine(OnClick());
|
|
}
|
|
|
|
private IEnumerator OnClick()
|
|
{
|
|
SetDownState();
|
|
yield return new WaitForEndOfFrame();
|
|
SetUpState();
|
|
}
|
|
public void SetUpState()
|
|
{
|
|
CrossPlatformInputManager.SetButtonUp(Name);
|
|
}
|
|
|
|
|
|
public void SetAxisPositiveState()
|
|
{
|
|
CrossPlatformInputManager.SetAxisPositive(Name);
|
|
}
|
|
|
|
|
|
public void SetAxisNeutralState()
|
|
{
|
|
CrossPlatformInputManager.SetAxisZero(Name);
|
|
}
|
|
|
|
|
|
public void SetAxisNegativeState()
|
|
{
|
|
CrossPlatformInputManager.SetAxisNegative(Name);
|
|
}
|
|
}
|
|
/*
|
|
[AddComponentMenu("Input/ButtonHandler")]
|
|
public class ButtonHandler : OnScreenControl
|
|
{
|
|
[HideInInspector]
|
|
public GenericInput action;
|
|
[Header("Name is deprecated")]
|
|
[Tooltip("The name is deprecated, use Control path instead.")]
|
|
public string Name;
|
|
|
|
[InputControl(layout = "Button")]
|
|
[SerializeField]
|
|
private string m_ControlPath;
|
|
private Button button;
|
|
|
|
protected override string controlPathInternal
|
|
{
|
|
get => m_ControlPath;
|
|
set => m_ControlPath = value;
|
|
}
|
|
|
|
public void SetAxisPositiveState()
|
|
{
|
|
CrossPlatformInputManager.SetAxisPositive(Name);
|
|
}
|
|
|
|
|
|
public void SetAxisNeutralState()
|
|
{
|
|
CrossPlatformInputManager.SetAxisZero(Name);
|
|
}
|
|
|
|
|
|
public void SetAxisNegativeState()
|
|
{
|
|
CrossPlatformInputManager.SetAxisNegative(Name);
|
|
}
|
|
|
|
public void Click()
|
|
{
|
|
StartCoroutine(OnClick());
|
|
}
|
|
|
|
private IEnumerator OnClick()
|
|
{
|
|
SetDownState();
|
|
yield return new WaitForEndOfFrame();
|
|
SetUpState();
|
|
}
|
|
private void Awake()
|
|
{
|
|
if(m_ControlPath == null)
|
|
{
|
|
Debug.Log("Null");
|
|
}
|
|
button = GetComponent<Button>();
|
|
}
|
|
|
|
|
|
public void SetDownState()
|
|
{
|
|
if (button != null && button.interactable == false) return;
|
|
CrossPlatformInputManager.SetButtonDown(Name);
|
|
|
|
//SendValueToControl(1.0f);
|
|
}
|
|
|
|
public void SetUpState()
|
|
{
|
|
if (button != null && button.interactable == false) return;
|
|
CrossPlatformInputManager.SetButtonUp(Name);
|
|
|
|
// SendValueToControl(0.0f);
|
|
}
|
|
|
|
}
|
|
*/
|
|
}
|