public override void Update() { m_prevValue = m_value; m_value = Input.GetAxis(Name); if (m_value != 0) { EventSafeCall(m_value); bLastUpdate = false; } else if (!bLastUpdate && m_value == 0) { EventSafeCall(0); bLastUpdate = true; } if (m_value == 0) { bNegativePressed = bPositivePressed = false; } if ((OnPositiveReleasedEvent != null && OnNegativeReleasedEvent != null) && m_prevValue != 0 && m_value == 0) { if (bPositivePressed) { OnPositiveReleasedEvent.SafeCall(); } if (bNegativePressed) { OnNegativeReleasedEvent.SafeCall(); } } else if (OnPositivePressedEvent != null && m_prevValue == 0 && m_value > 0) { bPositivePressed = true; OnPositivePressedEvent.SafeCall(); } else if (OnNegativePressedEvent != null && m_prevValue == 0 && m_value < 0) { bNegativePressed = true; OnNegativePressedEvent.SafeCall(); } if (OnPositiveStayEvent != null && bPositivePressed == true) { OnPositiveStayEvent.SafeCall(); } if (OnNegativeStayEvent != null && bNegativePressed == true) { OnNegativeStayEvent.SafeCall(); } }
public virtual void Update() { if (Input.GetAxis(Name) > 0) { bPositivePressed = true; if (OnPositivePressedEvent != null && Input.GetButtonDown(Name)) { OnPositivePressedEvent.SafeCall(); } else if (OnPositiveStayEvent != null) { OnPositiveStayEvent.SafeCall(); } } else if (Input.GetAxis(Name) < 0) { bNegativePressed = true; if (OnNegativePressedEvent != null && Input.GetButtonDown(Name)) { OnNegativePressedEvent.SafeCall(); } else if (OnNegativeStayEvent != null) { OnNegativeStayEvent.SafeCall(); } } else if (bPositivePressed) { if (OnPositiveReleasedEvent != null && !Input.GetButtonDown(Name)) { OnPositiveReleasedEvent.SafeCall(); } bPositivePressed = false; } else if (bNegativePressed) { if (OnNegativeReleasedEvent != null && !Input.GetButtonDown(Name)) { OnNegativeReleasedEvent.SafeCall(); } bNegativePressed = false; } }