[Unity] uGUIのイベントを他のオブジェクトに流す

# 昨日書いた記事の更新
昨日の記事：[[Unity] uGUIのボタンイベントを他のボタンに流す](http://qiita.com/drafts/c832e4cdba448e8c56f6/edit)
↑これはボタンのイベントだけ投げたけど、もう全部投げようよと思った。

# インスペクタ
![b446f9a1a991c17725d5d85e24845ac6.png](https://qiita-image-store.s3.amazonaws.com/0/15626/80eea117-149d-cc9e-25fb-062229933eca.png)

# コード
```csharp
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using System;

public class BypassEvent : MonoBehaviour,
        IPointerEnterHandler,
        IPointerExitHandler,
        IPointerDownHandler,
        IPointerUpHandler,
        IPointerClickHandler,
        IInitializePotentialDragHandler,
        IBeginDragHandler,
        IDragHandler,
        IEndDragHandler,
        IDropHandler,
        IScrollHandler,
        IUpdateSelectedHandler,
        ISelectHandler,
        IDeselectHandler,
        IMoveHandler,
        ISubmitHandler,
        ICancelHandler
{
    public GameObject target;
    private UnityEngine.EventSystems.EventTrigger et;
    private UnityEngine.UI.Button bt;

    void Awake()
    {
        et = target.GetComponent<UnityEngine.EventSystems.EventTrigger>();
        bt = target.GetComponent<Button>();
    }

    public void OnPointerClick(PointerEventData eventData)
    {
        if (!target.activeInHierarchy) return;
        if (et != null) et.OnPointerClick(eventData);
        if (bt != null) bt.OnPointerClick(eventData);
    }
    public void OnSubmit(BaseEventData eventData)
    {
        if (!target.activeInHierarchy) return;
        if (et != null) et.OnSubmit(eventData);
        if (bt != null) bt.OnSubmit(eventData);
    }
    public void OnPointerDown(PointerEventData eventData)
    {
        if (!target.activeInHierarchy) return;
        if (et != null) et.OnPointerDown(eventData);
        if (bt != null) bt.OnPointerDown(eventData);
    }

    public void OnPointerEnter(PointerEventData eventData)
    {
        if (!target.activeInHierarchy) return;
        if (et != null) et.OnPointerEnter(eventData);
        if (bt != null) bt.OnPointerEnter(eventData);
    }

    public void OnPointerExit(PointerEventData eventData)
    {
        if (!target.activeInHierarchy) return;
        if (et != null) et.OnPointerExit(eventData);
        if (bt != null) bt.OnPointerExit(eventData);
    }

    public void OnPointerUp(PointerEventData eventData)
    {
        if (!target.activeInHierarchy) return;
        if (et != null) et.OnPointerUp(eventData);
        if (bt != null) bt.OnPointerUp(eventData);
    }

    public void OnSelect(BaseEventData eventData)
    {
        if (!target.activeInHierarchy) return;
        if (et != null) et.OnSelect(eventData);
        if (bt != null) bt.OnSelect(eventData);
    }

    public void OnInitializePotentialDrag(PointerEventData eventData)
    {
        if (!target.activeInHierarchy) return;
        if (et != null) et.OnInitializePotentialDrag(eventData);
    }

    public void OnBeginDrag(PointerEventData eventData)
    {
        if (!target.activeInHierarchy) return;
        if (et != null) et.OnBeginDrag(eventData);
    }

    public void OnDrag(PointerEventData eventData)
    {
        if (!target.activeInHierarchy) return;
        if (et != null) et.OnDrag(eventData);
    }

    public void OnEndDrag(PointerEventData eventData)
    {
        if (!target.activeInHierarchy) return;
        if (et != null) et.OnEndDrag(eventData);
    }

    public void OnDrop(PointerEventData eventData)
    {
        if (!target.activeInHierarchy) return;
        if (et != null) et.OnDrop(eventData);
    }

    public void OnScroll(PointerEventData eventData)
    {
        if (!target.activeInHierarchy) return;
        if (et != null) et.OnScroll(eventData);
    }

    public void OnUpdateSelected(BaseEventData eventData)
    {
        if (!target.activeInHierarchy) return;
        if (et != null) et.OnUpdateSelected(eventData);
    }

    public void OnCancel(BaseEventData eventData)
    {
        if (!target.activeInHierarchy) return;
        if (et != null) et.OnCancel(eventData);
    }

    public void OnDeselect(BaseEventData eventData)
    {
        if (!target.activeInHierarchy) return;
        if (et != null) et.OnDeselect(eventData);
        if (bt != null) bt.OnDeselect(eventData);
    }

    public void OnMove(AxisEventData eventData)
    {
        if (!target.activeInHierarchy) return;
        if (et != null) et.OnMove(eventData);
        if (bt != null) bt.OnMove(eventData);
    }
}
```

# 備考
EventTriggerとButton書いた。
他のイベントはまだ使わないからいいや。