Search Unity

Event System + Touch Input Module = both needed?

Discussion in 'Scripting' started by Flybye, Jul 1, 2015.

  1. Flybye

    Flybye

    Joined:
    Mar 25, 2015
    Posts:
    100
    Are both of these scripts needed together? Im making a game for iOS. With both scripts enabled I get the error "Multiple EventSystems in scene...this is not supported." I noticed the event system has a drag threshold which will probably be needed.

    This error only comes up in the console when a collision is detected, and the code attached to that object is simply:

    Code (csharp):
    1.  
    2. private bool hit = true;
    3.  
    4.    // Use this for initialization
    5.    void Start () {
    6.    }
    7.    
    8.    // Update is called once per frame
    9.    void Update () {
    10.    }
    11.  
    12.    void OnCollisionEnter2D(Collision2D collision){  
    13.      if (hit) {
    14.        Application.LoadLevel(Application.loadedLevel);
    15.      }
    16.    }
    17. }
     
  2. Flybye

    Flybye

    Joined:
    Mar 25, 2015
    Posts:
    100
    Anyone have any ideas?
     
  3. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    3,201
    Clear your hierarchy of multiple EventSystems until you have just one.
     
    Kiwasi likes this.
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    You need one event system with the appropriate input modules attached. Unity will take care of sorting out which input module to use.

    The trick is you can only have one EventSystem component anywhere in the scene. This is normally taken care of for you, but you can occasionally run into problems if you call DontDestroyOnLoad on an EventSystem.
     
  5. Flybye

    Flybye

    Joined:
    Mar 25, 2015
    Posts:
    100
    I dont have any DontDestroyOnLoad, but I did just notice the multiple EventSystems.

    I have an object called EventSystem with scripts: Event System, Touch Input Module, Standalone Input Module.
    My actual object that moves has: Event System, Touch Input Module.

    Am I supposed to have the object EventSystem or are the scripts in the object that actually moves enough?
     
  6. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Use the object EventSystem. All that should be in this object is the EventSystem component and the InputModules. Nothing else.

    You don't need these objects anywhere else in the scene.
     
  7. Flybye

    Flybye

    Joined:
    Mar 25, 2015
    Posts:
    100
    Perfect. TY