Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more..
    Dismiss Notice
  3. Dismiss Notice

MissingMethodException: Method not found.

Discussion in 'WebGL' started by AleVerDes, Jul 13, 2022.

  1. AleVerDes

    AleVerDes

    Joined:
    Jun 16, 2014
    Posts:
    35
    Hi all. I have a problem that the callbacks from the html page cannot find the methods in the Unity application. At the same time, the methods exist, I manually call them in the script itself, and the correct method signature (namespace, class and method name) is indicated in the error. What could be the problem?

    upload_2022-7-13_17-8-15.png

    upload_2022-7-13_17-8-37.png

    The methods themselves, when called from Start, work correctly and write what they need to the log. But as soon as I try to do it through the callback, the above error is written. Below is a screenshot of how my callbacks are arranged.

    upload_2022-7-13_17-10-24.png

    Where 'method' is 'InvokeOpened', 'InvokeError', 'InvokeUserRewaaard' etc.


    My Unity is 2021.3.6f1
     
  2. AleVerDes

    AleVerDes

    Joined:
    Jun 16, 2014
    Posts:
    35
    Tried adding link.xml, didn't work.
    upload_2022-7-13_17-35-0.png
     
  3. mpfrolovstud

    mpfrolovstud

    Joined:
    Dec 6, 2022
    Posts:
    1
    I got the same trouble with connect of yandex sdk to my webgl game. Did you solve that?
     
  4. pansoul

    pansoul

    Joined:
    Jan 8, 2020
    Posts:
    9
    Hi! You should check a value that you send via Send Message() in JS. It must correspond with allowed types for this method: string, number or empty (Documentation: https://docs.unity3d.com/Manual/webgl-interactingwithbrowserscripting.html).

    And each type should correspond to these types in C# scripts (js => C#):
    • string => string
    • number => float

    Examples:
    1. Code (JavaScript):
      1. instance.SendMessage('ObjectName', 'MethodName', 'string')
      =>
      Code (CSharp):
      1. ObjectName.MethodName(string value)
    2. Code (JavaScript):
      1. instance.SendMessage('ObjectName', 'MethodName', 3)
      =>
      Code (CSharp):
      1. ObjectName.MethodName(float value)
    3. Code (JavaScript):
      1. instance.SendMessage('ObjectName', 'MethodName', 7.5)
      =>
      Code (CSharp):
      1. ObjectName.MethodName(float value)
     
    Last edited: Jul 5, 2023