I am facing a strange issue on Unity version 5.6.4p4 The code compiles and runs just perfectly fine in editor but when I build it for android I see an error message saying that my method doesn't exists. I have checked many times but there is no such issue. I am not doing anything wrong. Can anyone suggest what could be wrong ?

enter image description here

  • 1
    \$\begingroup\$ Have you any preprocessor directives in your code somewhere? \$\endgroup\$ – Hellium Jan 17 '18 at 11:16
  • \$\begingroup\$ holy moly! I was going all crazy. I wasn't able to discover. I tried everything. Only after your comment I came to know that I have generated the method through Visual Studio and it has placed the method in the UnityEditor section of my class. That was causing issue ! \$\endgroup\$ – Adnan Nazir Jan 17 '18 at 11:51

As mentioned by @Hellium The issue was that I generated my method through Visual studio tool which placed my method in editor only region of my class. That's why it wasn't compiling when I built for android. Lesson Learnt: Don't rely on auto code generation always :D They put your code anywhere ! Even in places that aren't always correct.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.