Book Image

Mastering Unity 5.x

By : Alan Thorn
Book Image

Mastering Unity 5.x

By: Alan Thorn

Overview of this book

Mastering Unity 5.x is for developers wishing to optimize the features of Unity 5.x. With an in-depth focus on a practical project, learn all about Unity architecture and impressive animation techniques. With this book, produce fun games with confidence.
Table of Contents (16 chapters)
Mastering Unity 5.x
Credits
About the Author
Acknowledgment
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Creating a WordList class


Now we must build a class to process the word list asset. This involves a class that can open and read the word list itself, select a word at random from the list, and compare two words for a match. The latter is needed to compare the typed word with the selected word from the dictionary. To start with, a new Singleton class  WordList.cs should be created. The basic skeleton follows:

Note

For more information on Singleton objects, see Chapter 3, Player Controls - Movement. In addition, you can view the Unity online Wiki here: http://wiki.unity3d.com/index.php/Singleton.

using UnityEngine; 
using System.Collections; 
using System.Collections.Generic; 
//------------------------------------ 
public class WordList : MonoBehaviour 
{ 
   //------------------------------------ 
   //Members for Singleton 
   public static WordList ThisInstance 
   { 
         get 
         { 
               //Get or create singleton...