Advertisement
Guest User

Poprawka-2

a guest
Aug 17th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.EventSystems;
  5.  
  6. public class ButtonInput
  7.     : MonoBehaviour, IPointerDownHandler, IPointerUpHandler
  8. {
  9.     SerializeField
  10.     GameObject m_Target; // do czego wysyłać event
  11.    
  12.     float m_TargetDirection; // -1 w lewo / 1 w prawo
  13.     float m_Direction;
  14.  
  15.     // Use this for initialization
  16.     void Start()
  17.     {
  18.         m_Direction = 0.00f;
  19.     }
  20.  
  21.     // Update is called once per frame
  22.     void Update()
  23.     {
  24.         ExecuteEvents.Execute<IMovementHandler>(m_Target, null, (x, y) => x.Move(new Vector2(m_Direction, 0), false));
  25.     }
  26.  
  27.     public void OnPointerDown(PointerEventData eventData)
  28.     {
  29.         m_Direction = m_TargetDirection;
  30.     }
  31.  
  32.     public void OnPointerUp(PointerEventData eventData)
  33.     {
  34.         m_Direction = 0;
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement