Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Inserting a button spams my output with errors

Discussion in 'UGUI & TextMesh Pro' started by Kitt_nz, Jul 17, 2021.

  1. Kitt_nz

    Kitt_nz

    Joined:
    Oct 2, 2018
    Posts:
    2


    I'm using the new input system package and when I insert a UI button into the scene, I get all of these errors saying that I'm trying to read Input using the UnityEngine.Input class. I googled it and found out that I have to use events. I already made a script (attached to the button):

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.EventSystems;
    5.  
    6. namespace TurboTribble.Menu {
    7.     public class PlayButton : MonoBehaviour, IPointerClickHandler {
    8.         public MainMenuHandler handler;
    9.  
    10.         // Start is called before the first frame update
    11.         void Start() {}
    12.  
    13.         // Update is called once per frame
    14.         void Update() {}
    15.  
    16.         public void OnPointerClick(PointerEventData eventData) {
    17.             handler.OnPlay();
    18.         }
    19.     }
    20. }
    21.  
    And it still doesn't work. Even a button without any scripts produces those errors.