Game Development Reference
In-Depth Information
public float Speed = 1.0f;
//Name of Ogre
public string OgreName = "Harry";
//--------------------------------------------
//Override ToString method
public override string ToString ()
{
//Return a string representing the class
return string.Format ("***Class EnemyOgre*** OgreName:
{0} | Health: {1} | Speed: {2} | CurrentAttack: {3} |
RecoveryTime: {4}",
OgreName, Health, Speed, CurrentAttack, RecoveryTime);
}
//--------------------------------------------
void Start()
{
Debug.Log (ToString());
}
//--------------------------------------------
}
//--------------------------------------------
The output of the preceding code can be seen in the Console window, as shown here:
Overriding the ToString method to customize debug messages for a class
 
Search WWH ::




Custom Search