Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

CS1031 Type expected on Public class line

Discussion in 'Scripting' started by itsmesarvin, Jul 7, 2022.

  1. itsmesarvin

    itsmesarvin

    Joined:
    Jul 4, 2022
    Posts:
    2
    I was hit with a type expected on the Public class line I do not know what to do or what it means. I am 12 years old and need help. This code is a part of a inventory system where when the mouse hovers a slot the code detects it.

    using UnityEngine;
    using System.Collections;
    using System.Collections.Generic;

    public class Slot : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler, <------ This is where the error has occurred
    {
    public bool hovered;
    public bool used;


    private GameObject item;
    private Texture itemIcon;

    void Start()
    {
    hovered = false;
    }
    void Update()
    {

    }

    public void OnPointerEnter(PointerEventData eventData)
    {
    hovered = true;
    }

    public void OnPointerExit(PointerEventData eventdata)
    {
    hovered = false;
    }

    }
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    6,012
    You have an extra comma that doesn't need to be there just after
    IPointerExitHandler
    .
     
    Ryiah and Bunny83 like this.
  3. itsmesarvin

    itsmesarvin

    Joined:
    Jul 4, 2022
    Posts:
    2
    CS0246 error came on saying that IPointerEnterHandler and IPointerExitHandler and PointerEventData for two lines
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Ryiah and Bunny83 like this.
  5. Bunny83

    Bunny83

    Joined:
    Oct 18, 2010
    Posts:
    3,571
    Please don't throw error codes against us. You received an actual error message written in plain english. If you get an error, please copy that message. You can copy text from the bottom half of the console window when you select a log message.
     
    Ryiah likes this.