Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

Web Monetization once more

A topic by LightWeightBrah created Nov 23, 2020 Views: 245 Replies: 4
Viewing posts 1 to 5
Submitted (2 edits)

Hi I started implementing web monetization in Unity Engine. I saw on tutorial guy explaining how to implement web monetization also did spawning prefabs on monetization. But do I have to have any object that will be connected with web monetization? Can I just drag and drop 

"WebMonetizationBroadcaster" prefab on to every scene in my game and set there Payment Pointer? I am not sure so would be great if u answear.

"WebMonetizationBroadcaster" from WebMonetization Package > Prefabs

This tutorial.

Is there a way to put it into a global place? The payment pointer only needs to be set once most likely. Usually in the HTML itself.

Host

Did you try reaching out to the person from the tutorial to ask?

Submitted

Hi. You need to connect events to your own functions on OnEnable and remove them OnDisable.

private void OnEnable()
{
    WMBroadcaster.OnMonetizationStart += OnMonetizationStart;
    WMBroadcaster.OnMonetizationProgress += OnMonetizationProgress;
}
    
private void OnDisable()
{
    WMBroadcaster.OnMonetizationStart -= OnMonetizationStart;
    WMBroadcaster.OnMonetizationProgress -= OnMonetizationProgress;
}

In this code. right right side of operators are your own private methods.

https://learn.unity.com/tutorial/events-uh see here for more info about delegates and events.

Submitted

"WebMonetizationBroadcaster" prefab on to every scene in my game and set there Payment Pointer?

==> I did not notice about this before because I have used only 2 scenes in my game, the Main gameplay and a Leaderboard.  I only used above prefab in my Main scene, not in Leaderboard scene. (The extra feature for Coil user is not necessary in my Leaderboard). 

When reading your question, I have just tested Coil extension and saw that Coil is still paying during the time I'm watching Leaderboard. 

I have used the same Unity Github source as you, so I guess the answer is "No, you don't have to put the Broadcaster and Payment Pointer"  in every scene. Hope my answer is not too late for you (Sorry, I was so busy to submit the game on time).