Skip to content

Instantly share code, notes, and snippets.

@unitycoder
Created March 21, 2015 23:16
Show Gist options
  • Select an option

  • Save unitycoder/8310e7da082617ea125e to your computer and use it in GitHub Desktop.

Select an option

Save unitycoder/8310e7da082617ea125e to your computer and use it in GitHub Desktop.

Revisions

  1. unitycoder created this gist Mar 21, 2015.
    21 changes: 21 additions & 0 deletions gistfile1.cs
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    EventSystem eventSystem;
    //..
    void Start ()
    {
    GameObject go = GameObject.Find("EventSystem");
    if (go==null)
    {
    Debug.LogError("EventSystem not founded..");
    }else{
    eventSystem = go.GetComponent<UnityEngine.EventSystems.EventSystem>();
    }
    }
    // ..
    void Update ()
    {
    if (Input.GetMouseButtonDown(0))
    {
    if (eventSystem.IsPointerOverGameObject()) return;

    // do other stuff, since not hitting UI
    }