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 /
avatar image
4
Question by pgonzbecer · Jan 22, 2015 at 08:07 AM · c#scripting problem

Method not found, < Missing (Class).(Method) > on button OnClick() event

So I am barely new to Unity, but I have a great deal of experience in C#. So my question consists of a static method from a Player class that displays the deck to unity's debug console.

 // Shows the deck on the unity debugging console
 public static void dbgShowDeck(Player player)
 {
     for(int i= 0; i< player.deck.size+1; i++)
         Debug.Log(player.deck[i].ToString());
 }

But the problem is that unity doesn't register the dbgShowDeck method or any custom method I've made, and it does it to more than just the button entity.

alt text

I've looked around and the closest answer was the FindMissingScripts.cs from here. But it didn't solve my problem whatsoever. Does anyone know how to solve this problem?

capture2.png (6.0 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

3 Replies

· Add your reply
  • Sort: 
avatar image
8

Answer by cdrandin · Jan 22, 2015 at 10:01 AM

Taken from here You cannot assign a static method to an event trigger on onClick event.

I confirmed myself. It doesn't noticed the static method, however, when I remove the static and create it as an instance it works as normal.

Comment
Add comment · Show 2 · 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 DNRN · Jan 22, 2015 at 10:46 AM 0
Share

It depends on the version of Unity. I use 4.6.1f and I can use static methods as events, it is tested. I think the problem is the Player Class is not inherited from $$anonymous$$onoBehavior. I have answered this, but is currently waiting to get my answer approved...

avatar image pgonzbecer · Jan 23, 2015 at 02:23 AM 0
Share

Actually its not taken from there and that wouldnt solve the problem entirely. When you click on the combobox it gives me, one that says "Player" with more under it that have only all the static methods that I made plus monobehavior's static methods. But none of the instanced methods pop up there. I assumed that only static methods were feasable. And I must also add that the YourDeck has a script in it which contains the Player.cs script.

avatar image
1

Answer by DNRN · Jan 22, 2015 at 10:52 AM

I think it's because your Player class does not inherit from MonoBehaviour. If you let the Player class inherit from MonoBehaviour, Unity should be aware of the class, and you can use it in the editor e.g as an argument in a button event.

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 pgonzbecer · Jan 23, 2015 at 02:17 AM 0
Share

It does inherit $$anonymous$$onoBehaviour, thats how I was able to ask it to use a method from the scrip

avatar image
0

Answer by Fortyseven · Dec 30, 2015 at 06:58 AM

While not directly related to your question, it's worth noting that when I had a callback with the signature of public void SendStateMessage( object o = null ), I received the same issue, saying the method was 'missing'.

Once I changed it to a more specific type, like 'String', it worked as expected.

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

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

4 People are following this question.

avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

how to keep track of Lean Tween function? 0 Answers

Mirror : How to Sync child objects active status on join? 0 Answers

help with scripting combo 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