Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 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 /
This question was closed Apr 28 at 06:38 PM by CrusadingBanana for the following reason:

Found solution

avatar image
0
Question by CrusadingBanana · Apr 28 at 06:14 PM · script.eventsfunctions

event triggering one function, but not another

I stumbled upon a random problem I didnt think was possible. My game is a map strategy game, with countries visualy represented by tilemaps. Those tilemaps can be clicked, with an object that has a collider attached to it that follows the cursor. I decided to make a click of a country into an event, with an arguement of the country clicked. There are 2 listeners to the event, one in the same script as the event, its purpose is to simply Debug.Log(countryname) to monitor if everything is working fine. the 2nd one is an outside script that handles what to do with the clicks, currently it only has a "country selection" mechanism. Problem is that the debug does not work every single time. (It rarely even works) alt text Visualy i can change my selected country, which is obvious with them changing color wherever i click, so the event is firing. But i only got the Debug message in the bottom of the screenshot after a 10th selection, countries triggering it are completly random. There is also another random problem of the USA being unclickable despite being the same as all other objects, which i dont seek an answer to in this post

Does anybody have the slightest idea what could be happening/Where to seek answers?

Here is the code of the events :

 public event EventHandler OnClick;
     public delegate void EventHandler(object? sender, OnClickEventArgs e);
     public class OnClickEventArgs : EventArgs {
         public CountryData country;
     }
 
     private void Onclick(object sender, OnClickEventArgs e) {
         if (hoveringOver != null && myPosition.overUI == false) {
             Debug.Log(hoveringOver.GetComponent<CountryData>().name);
         }
     }
 
     void Start() {
         OnClick += Onclick;
     }
 

And Here is the function that is always triggered by the event :

     private void OnClick(object sender, CursorMovement.OnClickEventArgs e) {
         OnDispClickEventArgs args = new OnDispClickEventArgs(e.country, gm.players[displayedIdx]);
         OnDispClick.Invoke(this, args);
     }
 
     private void Nothing(object sender, OnDispClickEventArgs e) {
 
     }
 
 Something Worth mentioning is that the collision system on tilemaps is shaky and does often change value from seing the tilemap collision and not seeing it due to every tile having its own collider, which might for some reason have an impact here.

unityproblem1.png (112.7 kB)
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

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

220 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image 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

Is it possible to make custom automatically-called methods like Start and Update? 0 Answers

is there a way to vary a function for different instances of the script?,is there a way to vary a function for different instances? 1 Answer

How to make bullet prefab take color of the character? 1 Answer

How to check which scene is loaded and write if code for it. 5 Answers

How to make the unity editor respond while a script is working? 2 Answers


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