Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by chris56728 · May 08, 2016 at 05:05 PM · c#uicanvasinterfacemember

C# - Error " does not implement interface member"

Hey guys,

I'm getting an error in my code that I don't understand. Any ideas on how to fix this?

Assets/OnClick_Button_Canvas.cs(11,14): error CS0535: OnClick_Button_Canvas' > does not implement interface member > UnityEngine.EventSystems.IPointerClickHandler.OnPointerClick(UnityEngine.EventSystems.PointerEventData)'

using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; using System.Collections; using TriviaQuizGame; using TriviaQuizGame.Types; using UnityEngine.EventSystems; using EasyWiFi.Core; using System;

 public class OnClick_Button_Canvas : MonoBehaviour, IPointerClickHandler
 {
     public Button buttonPrefab; //default button
 
     public TQGGameController tqgameController;
     private int index = 0;
     bool isPressed;
 
     public void OnPointerClick(PointerEventData data, ButtonControllerType button)
     {
         isPressed = button.BUTTON_STATE_IS_PRESSED;
 
         if (isPressed)
         {
             Debug.Log("Button Clicked");
             tqgameController.ChooseAnswer(index);
         }
         else
             Debug.Log("Button Released");
 
     }
 
 }

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
4

Answer by tanoshimi · May 08, 2016 at 05:11 PM

You've got the signature wrong for OnPointerClick. It should be

 OnPointerClick(PointerEventData eventData) { ... }

See http://docs.unity3d.com/ScriptReference/EventSystems.IPointerClickHandler.OnPointerClick.html

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bonfire-Boy · May 08, 2016 at 07:47 PM 0
Share

Also note that the error message is giving you this information.

avatar image
1

Answer by musicartslao · Apr 16, 2019 at 09:37 AM

I have the same issue here in version 201837 too ! I was using a coroutine to pulse and drag an object, my error message being: "MyEventHandlers.cs(10,47): error CS0535: 'MyEventHandlers' does not implement interface member 'IPointerEnterHandler.OnPointerEnter(PointerEventData)'"

But if you check my snippet:

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 //01 
 using UnityEngine.EventSystems;
 using UnityEngine.Events;
 using UnityEngine.UI;
 
 //02 add extra handlers
 public class MyEventHandlers : MonoBehaviour, IPointerEnterHandler, IDragHandler, IPointerExitHandler
 {
     //04 to make the object pulse, check if it is pulsing already
     private bool pulse = false;
     //04a and keep track of the time
     private float time = 0;
 
 
 
     //03 for IPointerEnterHandler, IDragHandler, IPointerExitHandler....
     public void OnDrag(PointerEventData eventData)
     {
         //
         //throw new NotImplementedException();
 
         //06b update the position of the object to the position to the mouse pointer in order to drag it with the mouse
         this.gameObject.transform.position = Input.mousePosition;
 
     }
     public void OnPointerEnter(PointerEventData eventData)
     {
         //
         //throw new NotImplementedException();
 
         //06 starts the coroutine
         pulse = true;
         StartCoroutine(PulseObject());
     }
     public void OnPointerExit (PointerEventData eventData)
     {
         //
         //throw new NotImplementedException();
 
         //06a set pulse
         pulse = false;
     }

I do implement IPointerEventHandler !

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Hellium · Apr 16, 2019 at 09:58 AM 0
Share

Your script does not throw such error in an empty project. Try

  1. Closing and reopening Unity

  2. Right-click on the script file + Reimport

  3. Close Unity, delete the Library folder next to your Assets folder, open Unity again

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

153 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to make a restart button pop up after character has died? 2 Answers

Updated with UI text element not correct (same frame) 0 Answers

UI penetration through objects. 1 Answer

Trigger Canvas UI with Collider? C# Help! 1 Answer

Need help with death screen 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges