Game Development Reference
In-Depth Information
Unity Specifics
Calling and Retrieving URLs
Unity provides a WWW() function that can make a URL request retrieving
data. As data can be sent and retrieved in any format, it makes it quite a
powerful feature. For calls to Web sites, data are collected in raw HTML.
You cannot display the webpage as it appears, but rather gather its
HTML code. XML and HTML Unity parser packages can be purchased
from the Unity Store should you wish to display a Web site inside a Unity
The following workshops demonstrate simple methods for sending
emails. In the latter exercise where a Web server is employed, the code
could be modified to support the sending of user data to a game server
for a multiplayer game. However, WWW calls are notoriously slow with
respect to a game server and this method would not be recommended
for live-action games, such as real-time car racing.
Unity Hands On
Sending Mail with Device Mail Client
Step 1. Create a JavaScript file named interface and add the code
shown in Listing 8.3 .
Listing 8.3 Sending a Simple Email Message from a Unity
function OnGUI()
" Email&body=from Unity App ");
Step 2. Attach this code to the Main Camera.
Step 3. This code won't work in the Unity Editor. Build and push the
app to a mobile phone.
Step 4. Run the app. When you push the Send button, the email client
installed on the device will open with the subject and body lines
already included.
Step 5. To send more information from the app to email client, modify
interface.js to that in Listing 8.4 .
Search Nedrilad ::

Custom Search