Object.ToString Manual     Reference     Scripting  
Scripting > Runtime Classes > Object
Object.ToString

function ToString () : string

Description

Returns the name of the game object.

JavaScripts
Debug.Log(gameObject);

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
void Awake() {
Debug.Log(gameObject);
}
}

import UnityEngine
import System.Collections

class example(MonoBehaviour):

def Awake():
Debug.Log(gameObject)