purchases-unity icon indicating copy to clipboard operation
purchases-unity copied to clipboard

Non MonoBehaviour implementation of Purchases.cs

Open StephenHodgson opened this issue 5 months ago • 6 comments

It'd be really great and more useful if the Purchases.cs class wasn't a MonoBehaviour.

I can understand the ease of use for most unity devs to want it, but it more than likely be a scriptable object with the settings, and the rest of the classes be plain old c# objects (POCO).

Atm I have to instantiate this prefab/MonoBehaviour object into the scene in order to use the API, but most of my application logic is outside of the scene objects. (scene objects are only for UI/User interactions). I am programmatically setting up the Purchases object, so no MonoBehaviour should be required.

StephenHodgson avatar Jun 27 '25 19:06 StephenHodgson

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

RCGitBot avatar Jun 27 '25 19:06 RCGitBot

Related to PR #482

StephenHodgson avatar Jun 30 '25 14:06 StephenHodgson

Hi @StephenHodgson,

After chatting with the team, we think this would indeed be a better way to provide the API for Purchases. Unfortunately we won't have the bandwidth to tackle this right now but we have taken note and added it to our backlog. Thank you very much for your feedback!

Do let us know if you have any more ideas, we are always happy to receive feedback!

tonidero avatar Jul 02 '25 16:07 tonidero

Thanks @tonidero

I would very much like to do this work for you. I actually already submitted an application on your careers page. It wouldn't take me very long to do and have lots of experience doing this sort of thing.

StephenHodgson avatar Jul 02 '25 18:07 StephenHodgson

It'd be really great and more useful if the Purchases.cs class wasn't a MonoBehaviour.

This would be awesome but it won't be straightforward.

This library uses native plugins under the hood and there are two ways to communicate between unity <-> native code

UnitySendMessage requires MonoBehavior and it's easy & safe. You don't need to deal with type checking, making sure everything is on main thread etc. Would expect no serious crashes. Delegates, however, requires objects to be set up, and make sure you move your logic to main thread (because unity runs on main thread) and any failures would lead to hard crashes.

cihadturhan avatar Aug 19 '25 08:08 cihadturhan

I'm aware but I'm up to the challenge.

I've written multiple plugins with native interop.

StephenHodgson avatar Aug 19 '25 17:08 StephenHodgson