Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.EventSystems;
- public class ButtonInput
- : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
- {
- SerializeField
- GameObject m_Target; // do czego wysyłać event
- float m_TargetDirection; // -1 w lewo / 1 w prawo
- float m_Direction;
- // Use this for initialization
- void Start()
- {
- m_Direction = 0.00f;
- }
- // Update is called once per frame
- void Update()
- {
- ExecuteEvents.Execute<IMovementHandler>(m_Target, null, (x, y) => x.Move(new Vector2(m_Direction, 0), false));
- }
- public void OnPointerDown(PointerEventData eventData)
- {
- m_Direction = m_TargetDirection;
- }
- public void OnPointerUp(PointerEventData eventData)
- {
- m_Direction = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement