Preventing your game from running on unknown servers

After all the hard work you've had to go through to complete your web game project, it wouldn't be fair if it ended up generating traffic and income on someone else's website. In this recipe, we will create a script that prevents the main game menu from showing up unless it's hosted by an authorized server.

Getting ready

To test this recipe, you will need access to a webspace provider where you can host the game.

How to do it...

To prevent your web game from being pirated, follow these steps:

  1. From the Hierarchy view, use the Create drop-down menu to create a UI Text GameObject (Create | UI | Text). Name it Text – warning. Then, from the Text component in the Inspector, change its text field to

Get Unity 5.x Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.