Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

IAP Button goes missing...

Discussion in 'Unity IAP' started by Evorlor, Nov 6, 2017.

  1. DavidSmit

    DavidSmit

    Joined:
    Apr 1, 2014
    Posts:
    47
    @JeffDUnity3D I tried to recreate the problem with a new project in 2017.4.1f1, but couldn't. Even after removing the library, and the plugins, it seemed to be fine.

    I did notice that if I removed UnityChannel and UnityPurchasing folders from Plugins, and did the import again, I got the proper import structure. While my other project, if I did the same thing, it refused to properly(automatically) install the plugins. It only downloaded the packages, that I had to manually install them. - So I'm guessing that's where the problem started.

    Unsure what went wrong or is wrong with my other project. Perhaps an upgrade from 2017.3 or Git or Mac/Win syncing.
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,855
    @DavidSmit Sounds like you are on the right track.
     
  3. kwikdev

    kwikdev

    Joined:
    Jun 13, 2013
    Posts:
    25
    I'm actually seeing it again in 2017.4.1f1 but only on Unity Cloud Build.

    It seems to now work locally after an upgrade and a Library reload, which wasn't true before.

    However, on Unity Cloud Build still see this error for each IAP button:
    780: [Unity] Script attached to 'IAP_Button' in scene 'Scene.unity' is missing or no valid script is attached.

    Tried clearing the cache and that didn't help. UCB is set to 2017.4.1f1 also.

    We do prefer to use the IAP button as it's all set up. The Codeless IAP system is a a nice solution and we definitely want to leverage it.

    However - a simple workaround would be fine. Do you guys know the root cause so we can try some things; or have a clever workaround in mind? This is a strange bug, unlike any I've seen.
     
  4. kwikdev

    kwikdev

    Joined:
    Jun 13, 2013
    Posts:
    25
    Maybe this is a clue, or maybe it's a separate issue:

    When the Unity IAP system is deleted and re-installed it causes a warning about obsolete APIs.

    The upgrade then modifies both UnityPurchasing/Bin/Editor.dll and UnityPurchasing/Bin/Stores.dll files. Screen Shot 2018-04-15 at 7.28.44 AM.png Screen Shot 2018-04-25 at 2.37.10 PM.png
     
  5. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,855
    The API Update is expected when you reimport/install and is required. One work around you might try is to make any edit to IAPButton.cs and push to Cloud Build.
     
  6. kwikdev

    kwikdev

    Joined:
    Jun 13, 2013
    Posts:
    25
    Jeff, I have tried the IAPButton.cs workaround. Created a brand-new script called IAPButton.cs and pasted the contents across. Problem persists.

    I can also still reproduce the missing IAPButton.cs issue in Unity Editor 2017.4.1f1 by detaching / re-attaching my project to Unity Services and re-installing IAP without a Library reload. See attached.

    The error itself doesn't even make sense, "The associated script cannot be loaded. Please check any compile errors and assign a valid script". But there are no compile errors in the Console! Haven't seen this behavior ever before in Unity.

    At this point, here's my understanding:

    1. Unity 2017.4.1f1 is the current long-term Unity release
    2. The Codeless IAP solution does NOT work in 2017.4.1f1
    3. There is no known workaround


    Screen Shot 2018-04-28 at 8.30.12 AM.png
     
    Last edited: Apr 30, 2018
  7. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,855
    @kwikdev Codeless IAP is working for me without issue in 2017.4.1f1. And apologies, I didn't mean a new IAPButton.cs script, rather suggesting instead to simply add a new line or similar in the existing file to force it to recompile. Also, does this happen with a new/empty project? Are you testing on a local build? A previous user had a similar issue, and it was because the hard drive folder was marked Read Only where the project was originally saved, and there were no errors in the Console. As a test, try creating/moving the project under the C:\Users\[username]\Documents folder (if on Windows), and try running Unity as an Administrator. Also try importing IAP on a new/empty project, create a Canvas and place a Codeless IAP button.
     
  8. kwikdev

    kwikdev

    Joined:
    Jun 13, 2013
    Posts:
    25
    Do your test projects build successfully on Unity Cloud Build?
     
  9. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,855
    Did you follow my instructions previously, editing IAPButton.cs directly to force a recompile? Also, can you test on a new/empty project with only IAP imported and a single Codeless button in the scene? I will test on Cloud Build also.
     
  10. kwikdev

    kwikdev

    Joined:
    Jun 13, 2013
    Posts:
    25
    Yes, on the IAPButton.cs test - this fixes the issue locally but does not stick on Cloud build. Currently I am trying a replacement of IAPButton.cs with a new IAPButtonRad.cs class outside the UnityPurchasing namespace. This seems to compile and may be my workaround.
     
  11. kwikdev

    kwikdev

    Joined:
    Jun 13, 2013
    Posts:
    25
    Hmm, not a fix. Even renaming the class and rewriting it a bit failed for me at runtime after a Cloud build. My conclusion (theory) is that there is *still* some issue deep in the store .dlls and / or the IAPButton.cs class and how they interconnect. Maybe it's specific to my projects, yet I would expect it to affect others in some scenarios.

    Ultimately, as I dug into the IAPButton.cs code and Codeless IAP system, I realized that a "Codeful IAP" solution will serve my needs best long-term. Have rewritten the IAP stuff to suit my needs precisely.

    @JeffDUnity3D - Thank you for working on this issue so diligently. Appreciate it!
     
  12. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,855
    I believe what may be happening on Cloud Build (not confirmed) is that the UNITY_PURCHASING directive may not be defined in the expected order, and is not available at compile time for these files. I am continuing to investigate, but may take a few days.
     
  13. savantedroid

    savantedroid

    Joined:
    Oct 8, 2015
    Posts:
    4
    This problem still continues with 2018.1 and I didn't delete any libraries.
     
    Qbit86 likes this.
  14. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,855
    @savantedroid Are you using Cloud Build? Does it build locally?
     
  15. thibouf

    thibouf

    Joined:
    Mar 17, 2017
    Posts:
    67
    Just to confirm, problem still there with Unity 2018.1 in cloud build.
     
    Qbit86 likes this.
  16. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,855
    @thibouf can you confirm that it builds locally?
     
  17. thibouf

    thibouf

    Joined:
    Mar 17, 2017
    Posts:
    67
    Yes no problem locally . And removing UNITY_PURCHASING directives still fix the problem on cloud build.
     
  18. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,855
    @thibouf Can you elaborate on your statement "And removing UNITY_PURCHASING directives still fix the problem on cloud build". Did you mean to say "still does NOT fix the problem.."?
     
  19. thibouf

    thibouf

    Joined:
    Mar 17, 2017
    Posts:
    67
    No I mean "do fix the problem".

    What I mean, is, like I already said in a previous post, it seems that the directive IS the problem (with cloud build). The MonoBehaviour in the scripts is not found with the UNITY_PURCHASING directive, leading to compilation errors.

    So removing the directive from the files fix the problem (or let's say, it's a workaround), and allow to compile in cloud build.
     
  20. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,855
    @thibouf Are you still able to use IAP in the cloud build version of the application, after removing the UNITY_PURCHASING directive? I would not expect IAP to work after removing the directive, and as such, I would not consider it a valid work around. Testing cloud build with IAP is on my task list, hopefully I can confirm the issue soon.
     
  21. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,855
  22. thibouf

    thibouf

    Joined:
    Mar 17, 2017
    Posts:
    67
    @JeffDUnity3D Yes removing UNITY_PURCHASING works, and IAP works, so it IS a valid workaround. (However I hope you will find and fix the actual issue)


    I won' have the time soon to test your project sorry. Anyway, as the problem appears on cloud build, I don't see how me doing it would change anything.
    Also, keep in mind that it seems that this problem is a bit random, and I suspect it might be triggered with bigger projects. On a previous project, it was working right after I integrated IAP, and then it stop compiling after I changed something totally unrelated. Also, I may build on Android and bot on iOs.
     
  23. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,855
    The sooner we have steps to reproduce with a project, the sooner we can identify and hopefully address the problem. I tested Code and Codeless IAP on Cloud Build without issue. We would need a minimal project that reproduces the issue. Also, please provide the Cloud Build logs on a failed build. In the meantime, I might suggest that you try manually defining UNITY_PURCHASING under Player Settings/Other Settings/Scripting Define Symbols
     
    Last edited: Jul 16, 2018
  24. ercion

    ercion

    Joined:
    Aug 15, 2016
    Posts:
    69
    I couldn't add the IAP Button either. When I'd drag and drop the script to add it manually, the editor would tell me that it can't find a MonoBehaviour or the class name doesn't match the file name. I removed the UNITY_PURCHASING directive from IAPButton, let it compile, and added the directive back again, and it started working. Seems to me that when I turned the IAP off, it excluded the class from the project. But it wasn't compiling this class after adding the directive back again.
     
  25. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,855
  26. Qbit86

    Qbit86

    Joined:
    Sep 2, 2013
    Posts:
    412
    I have similar issue not connected to Unity IAP, but probably related to dropping Library/ :
    https://forum.unity.com/threads/unity-fails-to-load-outdated-project.590842/
    Nothing Selected everywhere, no sensible compilation errors.


    Do you have any news on this issue?

    Windows, Unity 2017.2.4, Android, IL2CPP, .NET 4.6.
     
  27. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,855
    @Qbit86 Sorry we would only be able to answer IAP questions in this forum, I might suggest the Android forum.
     
  28. xsasoftware

    xsasoftware

    Joined:
    Sep 6, 2017
    Posts:
    11
    I always face this problem.
    Steps to repro:
    1. Make a new project.
    2. Add IAP Buttons
    3. Save on cloud.
    4. Delete project from local disk
    5. Import project from the cloud.
    6. Button scripts error(because missing)

    Am I doing something wrong?
     
  29. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,855
    You likely removed the Library folder or some other needed file. That is likely the issue. If not, then you'll need to do a diff.
     
  30. xsasoftware

    xsasoftware

    Joined:
    Sep 6, 2017
    Posts:
    11
    I will check next time, and come with an answer. ( but all the time when this happen, the iap button scripts are in folders, but are not visible on the "Add Component" menu.
     
  31. negerton

    negerton

    Joined:
    Apr 26, 2017
    Posts:
    7
    @JeffDUnity3D we recently communicated on this in another thread, but in racking my brain trying to solve this issue for nearly two weeks now, I still haven't found a solution.

    I'm able to reproduce this issue in 2019.1.2f1 in a fresh project.
    1. Create a new project
    2. Enable in-app purchasing in Services
    3. Import In-App purchasing package
    4. Create IAPButton object, assign Product ID, save scene and close project
    5. Delete library folder
    6. Re-open project; results in the IAP button reverting to "The associated script can not be loaded" on the IAP button
     
  32. wagenheimer

    wagenheimer

    Joined:
    Jun 1, 2018
    Posts:
    81
    I have the same problem on Unity 2019.1.3f1, when trying to create locally an android build, all IAP Button now shows the error "The Associate Script Cannot be Loaded".

    That is true, this is what happens here!
     
  33. wagenheimer

    wagenheimer

    Joined:
    Jun 1, 2018
    Posts:
    81
    Another problem. IAPListener does not appears on Add Component.
    But I can find it searching for it on the project. But I still cannot add it to a gameobject.

    upload_2019-5-24_11-11-52.png
     
  34. xsasoftware

    xsasoftware

    Joined:
    Sep 6, 2017
    Posts:
    11
    I have the same problem.
     
  35. wagenheimer

    wagenheimer

    Joined:
    Jun 1, 2018
    Posts:
    81
    I was able to fix it, but I'm not sure what I have done. But I'm sure It's something wrong with the #define not working as expected!
     
  36. mr-satru

    mr-satru

    Joined:
    Aug 7, 2014
    Posts:
    20
    2019.1.4f - same problem.
    After compile IAPButtons are missing scripts
     
  37. negerton

    negerton

    Joined:
    Apr 26, 2017
    Posts:
    7
    @JeffDUnity3D any more updates on this? it's clear that the issue is not resolved.

    I'm not trying to come off as inflammatory, or to hold your feet to the fire; I know dev priories are what they are and things change. But with that said, on January 18 2018 you mentioned this was being investigated as a high priority; then, 3 months later, it was said to be fixed. As per the responses here, and the test I outlined above, this is clearly still an issue; the underlying problem of this plugin being heavily dependent on the Library folder has not been addressed.

    I understand git/version control is outside the scope of your support, but at the same time, Unity surely must recognize that such a thing is common practice among unity devs of all professional/skill levels. This plugin being fundamentally not compatible with GIT is problematic, time consuming, and risky; and the likely outcome barring a fix here is I'll simply have to find another plugin to use. This is rather disappointing, as I like Unity's IAP solution otherwise.

    I suppose what I'm saying is that it would be helpful to know if there are currently no plans to address this issue, as I can begin searching for (or developing) another solution.
     
  38. mr-satru

    mr-satru

    Joined:
    Aug 7, 2014
    Posts:
    20
    I think my problem has the same reason. I transmit project by GIT with typical .gitignore (Library folder is excluded) and get it, then remove and reinstall plugin and it worked.
     
  39. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,855
    I swear we had this fixed previously, my mistake if not. I've had users send me projects with the Library folder removed before zipping, and the project worked. Hmm...perhaps I had always immediately updated IAP to the latest version, which may have masked the issue and certainly not a work around here. At any rate, it sounds like it's back/still here. Agreed, the Library folder can become VERY large, and ideally ignored in source control.
     
  40. negerton

    negerton

    Joined:
    Apr 26, 2017
    Posts:
    7
    Thanks for the response. @JeffDUnity3D

    Yes, immediately removing/reimporting Unity IAP will mask the issues in some ways - as it will cause IAP buttons to properly compile as IAP objects. However, while this method serves to properly re-link the IAP scripts to the intended objects, button-specific settings are not preserved (SKU, type of button, etc.) and need to be reconfigured (while overall catalog details ARE preserved).

    It seems those particular settings are contained within the assetDatabase3 file within the library folder, as the issue can be reproduced by simply removing that file. Or, perhaps the serialized data is lost when the plugin is re-imported from this state?
     
  41. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,855
    Undetermined, but I have already reported this issue here. Hopefully it will get some attention. However, it looks like something may have changed in the Editor, and unfortunately Editor issues can take a longer time to address due to QA and integration testing. But not certain yet.
     
  42. etherny1234

    etherny1234

    Joined:
    Mar 10, 2015
    Posts:
    3
    @JeffDUnity3D any news about this issue ?
    I have the same problem using iapbutton (with codeless)
    Works locally but when repo pulled on another computer I have a missing behaviour on button.
    I m using 2019.1.7f1 version.

    IAPButton.cs is present in the git re^po and pulled on clone.

    I can add new IAPButton on the second computer in editor without issue, but IAPButton added by the first computer (who push the code to the git repo) and pulled by second not working.

    It's the same issue than on Unity Cloud but on my personnal gitlab ci.
     
    Last edited: Jun 22, 2019
  43. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    4,855