Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 /
avatar image
0
Question by mike29willems · Mar 10, 2019 at 03:31 PM · canvasevent triggeringreferencing

How to add ur own function/script to event trigger in canvas?

I have a Jump button in canvas that I wanna reference to my own script when someone touches it (mobile). I added my own script to the button object and an event trigger component. When I tried to select my script in the event trigger component I couldn't see my own function... (Canvas-> JumpButton->event trigger-> add new event type-> pointer click->button->?). Do I have to use a function from Unity or can I use my own? Thanks in advance!

Comment
Add comment · Show 2
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 kamran-bigdely · Mar 10, 2019 at 03:45 PM 0
Share

Can you provide your script? Also make sure your function is public.

avatar image zereda-games kamran-bigdely · Mar 10, 2019 at 03:50 PM 0
Share

not necessarily...

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by zereda-games · Mar 10, 2019 at 03:44 PM

         private Button ClearPurchasingDataButton;
         private string ClearPurchasingDataButtonTag = "ClearPurchasingDataButton";
         void Awake()
         ClearPurchasingDataButton = GameObject.FindGameObjectWithTag(ClearPurchasingDataButtonTag).GetComponent<Button>();

         ClearPurchasingDataButton.onClick.AddListener(OnClearUnityPurchasingPath);

         }
         [MenuItem("Editors/ZeredaGamesEngine/Game Making Tools/Delete/Clear Unity Purchasing Path", false, 1)]
         public static void OnClearUnityPurchasingPath()
         {
                 if (EditorUtility.DisplayDialog("Clear Unity Purchasing Entries", "Are you sure you want to clear Unity Purchasing data for this project? ", "Clear", "Skip"))
     {
               string unityPurchasingPath = System.IO.Path.Combine(System.IO.Path.Combine(Application.persistentDataPath, "Unity"), "UnityPurchasing");
         if (System.IO.Directory.Exists(unityPurchasingPath))
         {
             System.IO.Directory.Delete(unityPurchasingPath, true);
         }
         if (Instance.DebugMode)
         {
             string message = System.DateTime.Now.ToString();
             Debug.Log("[" + message + "] [UNITY PURCHASING PATH CLEARED]");
         }
     }
 }



Link to more data

Comment
Add comment · 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
0

Answer by kamran-bigdely · Mar 10, 2019 at 03:53 PM

Your function that is going to be called by event trigger should be:

  1. public

  2. have a void return type

  3. take one or no parameter.

Comment
Add comment · Show 6 · 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 zereda-games · Mar 10, 2019 at 03:55 PM 0
Share

it doesn't Need to be public.... it's just less coding..

avatar image mike29willems · Mar 10, 2019 at 03:56 PM 0
Share

Yes it is but I cant see it. Do I maybe need to make a reference?

avatar image zereda-games mike29willems · Mar 10, 2019 at 03:57 PM 0
Share

look at my example above

avatar image zereda-games zereda-games · Mar 10, 2019 at 03:58 PM 0
Share

ps: Instance.Debug$$anonymous$$ode is a Static Debug$$anonymous$$ode on that script...

Show more comments

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

110 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

Related Questions

Where could errant "OnMouseEnter" and "OnMouseExit" events be coming from? 1 Answer

EventTrigger not working on Text element inside canvas 0 Answers

Using OnClick() with an empty GameObject 1 Answer

Assign EventTrigger reference Script at Runtime 1 Answer

EventTrigger.OnDrag on worldspace canvas 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