Game Development Reference
Unity Hands On
Step 1. Go to https://dev.twitter.com/apps/new and register your
application. This will give you a number of keys and authorization
values for your application. You can do this even if your application
is only for the personal testing purposes of this tutorial. After you
submit the application you will receive personalized codes
for your app. They will look something like this:
Keep these values handy as you will require them soon. Note that the
ones listed here are not real and will not work in your application.
Step 2. Create a new Unity project with a new Scene called
Step 3. Download and add Chapter Eight/PostTweet.js to the Project.
Step 4. Create a new folder in the Project called Plugins. Download
and add Chapter Eight/TwitterHelpers.js . The reason the .cs files go in
the Plugins folder is that we want Unity to compile them first—that
way the functions inside are ready for use by the PostTweet code.
Step 5. Attach PostTweet to the Main Camera.
Step 6. Modify the PostTweet code to include the OnGUI function
given in Listing 8.9 .
Listing 8.9 A GUI Interface to Handle Twitter Authorization
and Sending Tweets
//if they are authenticated show a tweeting box
GUI.BeginGroup (Rect (Screen.width / 2 — 200,
Screen.height / 2 — 60, 400, 120));
GUI.Box (Rect (0,0,400,120), ScreenName +
" Send Your Tweet");
Tweet = GUI.TextField(Rect(10,30,380,30), Tweet);
GUI.Label(Rect(310,70,80,30),"Chars = " + Tweet.length);