Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 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
2
Question by mirage3d · Sep 20, 2019 at 01:53 PM · eventsysteminterfaceevent triggering

Unable to assign callbacks in "Event Trigger" component in the inspector

I have been trying to assign delegate functions in scripts that are attached to game objects. I thought that there must be a better way to handle mouse clicks than the standard polling that everybody does in update(). I found the Unity tutorial about the click adventure game.


I have been trying high and low to replicate what they achieve, but nothing is working. I tried several Unity versions, thinking maybe it's a bug - currently using 2019.2.5f1, so I tried 2019.2.6f1, and 2019.3.0b3 and I get same results.


When I try to add any function that takes a BaseEventData or PointerEventData argument, they never show up in the list. Other functions that take a String argument or have no arguments show up fine. I scoured the net looking for tutorials, and most deal with customized even systems, or just deal with 0-argument functions.


I can add the functions as listeners through code, as they work when tested, but never through the interface which makes code not modular and beats the purpose of using the interface for assignment.


Has the API changed somehow? Or am I missing something? Anybody else experiencing such behavior?


Here is a screencap of what the interface lists. Notice that the PointerClick event does not have the BaseEventData parameter.

screencap

screenshot-4.png (80.2 kB)
Comment
Add comment · Show 4
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 mirage3d · Sep 20, 2019 at 08:53 AM 0
Share

Thank you Helium. That video is from 2014. Didn't know it still applies.

The Unity video tutorial I referred to is from 2016. Here he's writing the delegate function: https://youtu.be/zsOcALVNl0s?t=2083

And here they're registering the function in the "Event Trigger" component: https://youtu.be/zsOcALVNl0s?t=2579

It's like they're using a different version of the "Event Trigger" component!

The Unity scripting API manual also shows an example of how to register as a delegate with the EventTrigger object (second script example): https://docs.unity3d.com/2018.3/Documentation/ScriptReference/EventSystems.EventTrigger.html

I changed the parameter types to the ones you mentioned, and the function shows in the list. If the arguments passed should be primitive types, how are we going to get the event data that triggered the call-back ?

So far, it works by registering through code, though. So I think I think I'd follow $$anonymous$$urphy: "If it works, don't fix it".

Thanks again.

avatar image Hellium mirage3d · Sep 20, 2019 at 10:46 AM 1
Share

$$anonymous$$y bad, I was wrong, I've done a quick test with a very simple class

 using UnityEngine;
 using UnityEngine.EventSystems;
 
 public class NewBehaviourScript : $$anonymous$$onoBehaviour
 {
     public void Test(BaseEventData baseEventData)
     {
 
     }
 }

The Test function appears in the Dynamic BaseEventData list in the OnPointerClick event of an event trigger.

The very strange thing in the screenshot you have sent is that your OnPointerClick event does not have any parameter in the inspector:

alt text

I am on Unity 2019.1.13, so I don't believe this thing has changed on Unity 2019.2+

have you tried to remove the component and attach it again?

avatar image mirage3d Hellium · Sep 20, 2019 at 11:49 AM 0
Share

I have noticed that as well, which made me remark that it looks like they were using another version of the component than I was.

Now that I see that your version looks different than $$anonymous$$e as well, it could be a setting in my version of Unity maybe ? Or could it be a different version of the component/system ?

I removed the component and attached it back. Started 2 new clean projects. Tried the component on normal objects and on prefabs as well. All the attempts have the same effect.

I just removed Unity and Hub completely. Reinstalled. Using Unity 2019.2.5f1. Same effect. I checked the dates on the EventTrigger.cs and its Editor script. They were dated Sept 4 this year. So they are recent.

Edit to add: It looks like a reflection problem. So I checked the .Net version setting and used .Net 4.x, and IL2CPP ins$$anonymous$$d of $$anonymous$$ono => Same effect. I also downloaded the tutorial project and no change in the behavior. At first I thought, maybe I'm using a different version of the "System Event" asset, because it was under UI. But the tutorial explains that it's only one, and it's under the UI menu because this was introduced with the new UI system.

Thanks and cheers.

avatar image P_Jong · Sep 21, 2019 at 01:15 PM 1
Share

I also started to get this when I upgraded to Unity 2019.2.6f1 with BaseEventData. After 4 hrs of trying out things I can't get it to work. I agree with @mirage3d, I think this is a bug. Edit Add - Going back to my backups this was working for me in Unity 2019.2.4f1. But in Unity 2019.2.5f1 and Unity 2019.2.6f1 I can no longer assign callbacks in the Event Trigger.

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by P_Jong · Sep 23, 2019 at 12:09 PM

After I reported this bug, I was told it is a known issue and was directed to issue tracker I’d 1178687 “UNITYEVENT DRAWER NO LONGER HANDLES EVENTS IN NON-PUBLIC FIELDS CORRECTLY”

https://issuetracker.unity3d.com/issues/events-generated-by-the-player-input-component-do-not-have-callbackcontext-set-as-their-parameter-type

This issue says it is fixed in 2019.3 but the comments are mixed. One person said it works for them in 2019.3.0b4 and some said it does not work for them in 2019.3.0b4. For now I’m keeping my game at 2019.2.4f1 where it’s still working.

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 mirage3d · Sep 23, 2019 at 12:51 PM 0
Share

I also got that reply and was given the same issue number. $$anonymous$$y version of 2019.3.0b4 and 2019.1.14f1 work fine. I guess it's not fully resolved yet. Hope they will be able to track the reason soon and fix it once and for all.

avatar image
0

Answer by mirage3d · Sep 20, 2019 at 02:15 PM

It's definitely a reflection thing.

Unity version 2019.1 defaults to using .Net 4.x. Whereas both 2019.2 and 2019.3 beta default back to using .Net 2.x.

The procedure works out of the box in 2019.1 ( current available version is 2019.1.14f1). Both 2019.2 and 2019.3 fail, even if I change the API compatibility back to .Net 4.x ( whether before adding the component and restarting the project, or after adding the component).

I'm guessing it's a bug. will try to file a bug report.

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 mirage3d · Sep 23, 2019 at 03:46 AM 0
Share

Unity 2019.3.0b4 does not exhibit this behavior even though the player settings were set to use "mono" and .Net Standard 2.0. Thus, the above assumption that it has to do with reflection is wrong. It is still a bug though. I have filed a bug report. Hope they fix it soon.

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

187 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 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

onClick Event for UI Text? 1 Answer

UI stopped working 0 Answers

How to Event tigger when drag and drop complete 1 Answer

Calling a function through EventTrigger does not loop. 1 Answer

(Solved) OnPointerUp not called 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