Book Image

Unity 2017 Mobile Game Development

By : John P. Doran
Book Image

Unity 2017 Mobile Game Development

By: John P. Doran

Overview of this book

Unity has established itself as an overpowering force for developing mobile games. If you love mobile games and want to learn how to make them but have no idea where to begin, then this book is just what you need. This book takes a clear, step-by-step approach to building an endless runner game using Unity with plenty of examples on how to create a game that is uniquely your own. Starting from scratch, you will build, set up, and deploy a simple game to a mobile device. You will learn to add touch gestures and design UI elements that can be used in both landscape and portrait mode at different resolutions. You will explore the best ways to monetize your game projects using Unity Ads and in-app purchases before you share your game information on social networks. Next, using Unity’s analytics tools you will be able to make your game better by gaining insights into how players like and use your game. Finally, you’ll learn how to publish your game on the iOS and Android App Stores for the world to see and play along.
Table of Contents (11 chapters)

Sharing high scores via Twitter

Now that we have a scoring system, let's take a look at how we can share a high score using Twitter.

Twitter is an online news and social networking service where users post and interact with each other through messages that they call tweets, which are limited to 280 characters.

Twitter is a great option to start off with because it is very easy to add to our project by simply opening a specific URL:

  1. Open the PauseMenuBehaviour script. Once inside there, we will add the following code inside the PlayerMenuBehaviour class:
#region Share Score via Twitter 
 
// Web address in order to create a tweet 
private const string tweetTextAddress =  
                            "http://twitter.com/intent/tweet?text="; 
 
// Where we want players to visit 
private string appStoreLink = "http://johnpdoran.com/"; 
 
// Reference to...